Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run SVN commands from a python script?

Tags:

python

svn

Basically I want to write a python script that does several things and one of them will be to run a checkout on a repository using subversion (SVN) and maybe preform a couple more of svn commands. What's the best way to do this ? This will be running as a crond script.

like image 350
hopper Avatar asked May 15 '13 19:05

hopper


People also ask

What is svn in Python?

svn is a simple Subversion library for Python. I wrote it so that there could be a lightweight and accessible library that was also available on PyPI. It is compatible with both Python 2.7 and 3.3+. The library wraps the svn commandline client, which should consequently be installed on the local system.

How do I access svn files?

You can either store your repositories locally and access them using the file:// protocol or you can place them on a server and access them with the http:// or svn:// protocols. The two server protocols can also be encrypted. You use https:// or svn+ssh:// , or you can use svn:// with SASL.


2 Answers

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.

like image 34
Torxed Avatar answered Sep 19 '22 15:09

Torxed


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
like image 106
ovidoo83 Avatar answered Sep 18 '22 15:09

ovidoo83