当我将python脚本作为服务运行时,它不会读取远程存储库

2024-09-28 05:19:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我开发了一个python脚本,可以自动更新我的个人项目。 这个脚本是一个循环,它不断地查询gitlab存储库的标记,如果有新的标记,我们就继续进行合并。我希望脚本在服务上运行,但读取存储库时出错。你知道吗

当我直接在终端中运行脚本时,它会成功运行,但是当我创建并运行服务时,会有以下输出:

Traceback (most recent call last):
  File "/home/pi/sinapsis_update/update.py", line 128, in <module>
    main()
  File "/home/pi/sinapsis_update/update.py", line 115, in main
    repository()
  File "/home/pi/sinapsis_update/update.py", line 22, in repository
    repo_sinapsis.remote().fetch()
  File "/usr/local/lib/python3.5/dist-packages/git/remote.py", line 790, in fetch
    res = self._get_fetch_info_from_stderr(proc, progress)
  File "/usr/local/lib/python3.5/dist-packages/git/remote.py", line 674, in _get_fetch_info_from_stderr
    proc.wait(stderr=stderr_text)
  File "/usr/local/lib/python3.5/dist-packages/git/cmd.py", line 412, in wait
    raise GitCommandError(self.args, status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git fetch -v origin
  stderr: 'fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.'

我尝试给脚本(chmod u + xchmod 777)授予权限,但没有成功。 还可以按如下方式编辑文件~/.ssh/config

Host gitlab.com IdentityFile ~/.ssh/id_rsa IdentitiesOnly yes 但也没用。你知道吗

我希望该服务的工作方式与我直接从终端运行它时的工作方式相同。你知道吗

有什么想法吗?你知道吗


Tags: inpygit脚本homeremoterepositoryusr

热门问题