Mr. J Das
Mr. J Das

Reputation: 51

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

I am trying to connect SVN remote client and get the latest committed revision with following python codes in Windows:

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

I am getting following error:

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

I tried to print the "svnpath" and "r" to make sure it goes correct. I got as expected the correct remote server path (lets say "remote_path") for "svnpath" and < SVN(REMOTE) remote_path> for "r".

The remote SVN needs credential (UID & PWD) to access. However, the machine I use this script to run has already SVN setup with correct credentials. Do I need to still specify explicit credential in python scrip to access? If so then how? Or do I need any extra python package for SVN?

Please help...

Upvotes: 5

Views: 2606

Answers (2)

DRz
DRz

Reputation: 1156

I had the same error and fixed it by installing an SVN command line and adding it's path to the PATH environment variable.

If you're on Windows, you can install the command line executable when installing Tortoise SVN, but by default the corresponding option is not checked (see ccpizza's answer).

Upvotes: 1

Jean-Francois T.
Jean-Francois T.

Reputation: 12960

You probably solved your issue by then but looking at the code might help.

The class RemoteClient inherits from CommonClient which starts like this:

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)
   ...

Therefore, the following should work:

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())

Upvotes: 0

Related Questions