pythonsvnpre-commitsubversion-edge

python subprocess popen with arguments


I'm writing a precommit hook for svn and I have to run the "svnlook log" command, capture and parse its output.

I'm stuck at this point:

svnlookCmd = ['/appl/atlad00/CollabNetSubversionEdge-5.0.1/csvn/bin/svnlook', 'log', repoPath, '-t ', transID]
sys.stderr.write('svnlookCom = ' + str(svnlookCmd) + '\n')
svnlook = Popen(svnlookCmd, stdout=PIPE)
commitMsg = svnlook.stdout.read()
sys.stderr.write ("\n commit message is: : \n" + commitMsg + "\n")

This will run svnlook but complain svnlook itself will complain that "Too many arguments given" which is not true if you check the svnlook help.

So I thought I had to put "svnlook log" together like this:

['/appl/atlad00/CollabNetSubversionEdge-5.0.1/csvn/bin/svnlook log', repoPath, '-t ', transID]

But this will not run svn look at all giving me:

"OSError: [Errno 2] No such file or directory".

which it makes sense as:

'/appl/atlad00/CollabNetSubversionEdge-5.0.1/csvn/bin/svnlook log' does not exists.

Any idea of what I'm missing here? It's woth mentioning that it's a very long time since I have worked with python so I may be missing something very basic...

S.


Solution

  • found the issue:

    it's the space in the -t option:

    '-t '
    

    it should be

     '-t'