python - svn.remote.RemoteClient.info : FileNotFoundError: [WinError 2] The system cannot find the file specified

标签 python svn

我正在尝试连接 SVN 远程客户端并在 Windows 中使用以下 python 代码获取最新提交的修订版:

r = svn.remote.RemoteClient(svnPath)
revNum = str(r.info().get("commit#revision"))

我收到以下错误:

in \n revNum = str(r.info().get("commit#revision"))\n', ' File "C:\Program Files\Python36\lib\site-packages\svn-0.3.45-py3.6.egg\svn\common.py", line 75, in info\n do_combine=True)\n', ' File "C:\Program Files\Python36\lib\site-packages\svn-0.3.45-py3.6.egg\svn\common.py", line 54, in run_command\n return self.external_command(cmd, environment=self.env, **kwargs)\n', ' File "C:\Program Files\Python36\lib\site-packages\svn-0.3.45-py3.6.egg\svn\common_base.py", line 25, in external_command\n env=env)\n', ' File "C:\Program Files\Python36\lib\subprocess.py", line 709, in __init\n
restore_signals, start_new_session)\n', ' File "C:\Program Files\Python36\lib\subprocess.py", line 997, in _execute_child\n
startupinfo)\n']: [WinError 2] The system cannot find the file specified

我尝试打印“svnpath”和“r”以确保其正确无误。我得到了“remote_path”和“svnpath”的正确远程服务器路径(比如说“< SVN(REMOTE) remote_path>”)对于“r”。

远程SVN需要凭据(UID & PWD)才能访问。但是,我使用此脚本运行的机器已经使用正确的凭据设置了 SVN。 我是否仍需要在 python 脚本中指定显式凭据才能访问?如果是这样,那又如何?或者我需要任何额外的 SVN python 包吗?

请帮忙...

最佳答案

到那时您可能已经解决了问题,但查看代码可能会有所帮助。

RemoteClient 类继承自 CommonClient,它的开头如下:

class CommonClient(svn.common_base.CommonBase):
    def __init__(self, url_or_path, type_, username=None, password=None, 
                 svn_filepath='svn', trust_cert=None, env={}, *args, **kwargs):
        super(CommonClient, self).__init__(*args, **kwargs)
   ...

因此,以下应该有效:

import svn.remote

url = "http://server.com:8080/svn/SuperRepo/branches/tool-r20"

client = svn.remote.RemoteClient(url, username="toto", password="SuperPassword")
print(client.info())

关于python - svn.remote.RemoteClient.info : FileNotFoundError: [WinError 2] The system cannot find the file specified,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47700449/

相关文章:

python - 将日期添加到列表中,但 datetime.datetime 不可迭代

Python、pygame、py2exe

windows - 无法使用 svn+ssh 在 plink 中输入密码(或其他任何内容)

macos - Mac 命令行工具 11.4 不再有 svn

c# - 在 32 位和 64 位开发站上部署 .Net App Source Control (SVN)

python - 不同 Python dict() 中键的顺序

Python pandas张量访问极慢

python - 将 epoch/unix 时间转换为可读格式

svn - 如何导出(然后导入)Subversion 存储库?

svn - 如何在 SVN、Hg 或 Git 中标记一组更改/变更集