How to run SVN commands from a python script? How to run SVN commands from a python script? python python

How to run SVN commands from a python script?


Would this work?

p = subprocess.Popen("svn info svn://xx.xx.xx.xx/project/trunk | grep \"Revision\" | awk '{print $2}'", stdout=subprocess.PIPE, shell=True)(output, err) = p.communicate()print "Revision is", output


Try pysvn

Gives you great access as far as i've tested it.Here's some examples: http://pysvn.tigris.org/docs/pysvn_prog_guide.html

The reason for why i'm saying as far as i've tested it is because i've moved over to Git.. but if i recall pysvn is (the only and) the best library for svn.


Take a look into the python xonsh module: http://xon.sh/tutorial.html

It can call shell commands plus piping and output redirection with close touch to the python native code (nested) without need to play with python communicate bullshet and escape characters around.

Examples:

env | uniq | sort | grep PATH

COMMAND1 e>o < input.txt | COMMAND2 > output.txt e>> errors.txt

echo "my home is $HOME"

echo @(7+3)