Reputation: 13
I call
'svn di -revision <revNumber>:HEAD --summarize --xml >>svndiff.xml'
through subprocess.call(), and I get an error
svn: E020024: Error resolving case of '>>svndiff.xml'
If I type the same command into terminal, it works fine. Where is a trap?
Upvotes: 1
Views: 87
Reputation: 155465
In the terminal, >>svndiff.xml
gets interpreted by the shell. When using subprocess.call
in the default mode, such an argument gets passed to the svn
process literally. (You didn't show the actual subprocess.call
invocation, but given the error message, that's the most likely diagnosis.)
Instead, you must use the stderr
keyword argument to provide suitable output. For example:
with open('svndiff.xml', 'a') as log:
subprocess.call(["svn", "di", "--revision", "%s:head" % rev_number,
"--summarize", "--xml"], stdout=log)
or, you can use shell=True
to have the shell do it for you (with the usual pitfalls of shell parsing such as problems with file names containing spaces and shell injection):
subprocess.call("svn di --revision %s:HEAD --summarize --xml >>svndiff.xml" % rev_number,
shell=True)
Upvotes: 1