Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Subversion commit from Python?

Reply
Thread Tools

Subversion commit from Python?

 
 
Jack Trades
Guest
Posts: n/a
 
      05-19-2009
I'm wondering if there's an easy way to do a 'svn commit' on a
directory from Python.

More Details:
I have a wiki-like program that stores its data in a directory that I
would like to put under version control to be able to roll back
unwanted changes. The program is stored in two directories, a 'cgi'
directory which displays the data and allows user editing and a 'data'
directory. The 'data' directory is a checked-out version of the
repository.
Originally I had the 'data' directory in the same directory as the cgi
scripts and was using os.system("svn commit"), however I kept running
into weird bugs with this method. So I moved the data directory out
of the cgi directory and plan to use a separate repository. So is
there a prefered way to commit this directory to a subversion
repository from a Python script?
 
Reply With Quote
 
 
 
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      05-19-2009
In message <2904e7de-0a8d-4697-9c44-
>, Jack Trades wrote:

> Originally I had the 'data' directory in the same directory as the cgi
> scripts and was using os.system("svn commit"), however I kept running
> into weird bugs with this method.


What bugs?

 
Reply With Quote
 
 
 
 
Jack Trades
Guest
Posts: n/a
 
      05-19-2009
On May 19, 12:26*am, Lawrence D'Oliveiro <l...@geek-
central.gen.new_zealand> wrote:
> In message <2904e7de-0a8d-4697-9c44-
>
> c83bb5319...@s31g2000vbp.googlegroups.com>, Jack Trades wrote:
> > Originally I had the 'data' directory in the same directory as the cgi
> > scripts and was using os.system("svn commit"), however I kept running
> > into weird bugs with this method.

>
> What bugs?


I'm not 100% sure, but I think it had to do with executable
permissions on the cgi scripts. I would click on a link in the main
document (named 'add section') and it worked as expected. After
inserting the information for 'add section' and submitting it (info
was saved in the data folder, then a commit was done on the whole
project), clicking on the same 'add section' link would produce an
error (going back to the 'add section' script asked me to download it
instead of displaying it).

I'm using a very simple server to develop this on my computer...

import BaseHTTPServer
import CGIHTTPServer
import cgitb; cgitb.enable() ## This line enables CGI error reporting

server = BaseHTTPServer.HTTPServer
handler = CGIHTTPServer.CGIHTTPRequestHandler
server_address = ("", 8000)
handler.cgi_directories = [""]

httpd = server(server_address, handler)
httpd.serve_forever()

I got no information about the error at all, and after some time
completely gave up on it. I'm only guessing that it was a permissions
problem. I have made a huge number of modifications to the program
since then (about 2 days ago), and am unable to investigate it
further. I was just wondering if using os.system('svn commit') was
the right approach, or if there was a "more Pythonic" way of doing
this.
 
Reply With Quote
 
Tim Golden
Guest
Posts: n/a
 
      05-19-2009
Jack Trades wrote:
> I'm wondering if there's an easy way to do a 'svn commit' on a
> directory from Python.
>


http://pysvn.tigris.org/

and in particular:

http://pysvn.tigris.org/docs/pysvn_prog_guide.html

TJG
 
Reply With Quote
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      05-19-2009
In message <ac63e27e-2dd9-4c27-ace0-
>, Jack Trades wrote:

> On May 19, 12:26 am, Lawrence D'Oliveiro <l...@geek-
> central.gen.new_zealand> wrote:
>
>> In message <2904e7de-0a8d-4697-9c44-
>>
>> c83bb5319...@s31g2000vbp.googlegroups.com>, Jack Trades wrote:
>> > Originally I had the 'data' directory in the same directory as the cgi
>> > scripts and was using os.system("svn commit"), however I kept running
>> > into weird bugs with this method.

>>
>> What bugs?

>
> I'm not 100% sure, but I think it had to do with executable
> permissions on the cgi scripts.


Possibly your CGI scripts are running as some user like "nobody", which
doesn't have the right access to the files/directories. Changing APIs won't
help here.

 
Reply With Quote
 
Jack Trades
Guest
Posts: n/a
 
      05-19-2009
On May 19, 3:46*am, Duncan Booth <duncan.bo...@invalid.invalid> wrote:
> Jack Trades <JackTradesPub...@gmail.com> wrote:
> > Originally I had the 'data' directory in the same directory as the cgi
> > scripts and was using os.system("svn commit"), however I kept running
> > into weird bugs with this method. *So I moved the data directory out
> > of the cgi directory and plan to use a separate repository. *So is
> > there a prefered way to commit this directory to a subversion
> > repository from a Python script?

>
> Subversion has Python bindings, but for a friendlier interface have a look
> athttp://pysvn.tigris.org/
>
> An example from the docs athttp://pysvn.tigris.org/docs/pysvn_prog_guide.html:
>
> Commit changes to the repository
>
> import pysvn
> # edit the file foo.txt
> f = open('./examples/pysvn/foo.txt', 'w')
> f.write('Sample versioned file via python\n')
> f.close()
> # checkin the change with a log message
> client = pysvn.Client()
> client.checkin(['./examples/pysvn'], 'Corrected spelling of python in foo..txt')
>
> --
> Duncan Boothhttp://kupuguy.blogspot.com


Thanks that's what I was looking for.
 
Reply With Quote
 
Jack Trades
Guest
Posts: n/a
 
      05-19-2009
On May 19, 3:53*am, Lawrence D'Oliveiro <l...@geek-
central.gen.new_zealand> wrote:
> In message <ac63e27e-2dd9-4c27-ace0-
>
> d9e205be7...@s31g2000vbp.googlegroups.com>, Jack Trades wrote:
> > On May 19, 12:26 am, Lawrence D'Oliveiro <l...@geek-
> > central.gen.new_zealand> wrote:

>
> >> In message <2904e7de-0a8d-4697-9c44-

>
> >> c83bb5319...@s31g2000vbp.googlegroups.com>, Jack Trades wrote:
> >> > Originally I had the 'data' directory in the same directory as the cgi
> >> > scripts and was using os.system("svn commit"), however I kept running
> >> > into weird bugs with this method.

>
> >> What bugs?

>
> > I'm not 100% sure, but I think it had to do with executable
> > permissions on the cgi scripts.

>
> Possibly your CGI scripts are running as some user like "nobody", which
> doesn't have the right access to the files/directories. Changing APIs won't
> help here.


Thanks for the help, I'll have to look into that further. If that is
the case, would setuid be appropriate here? Or is there a better way
to give the script the appropriate permissions?
The only thing that baffles me is that the script works before a
commit and only sometimes after a commit, if it were an access problem
wouldn't it fail before the commit as well?
 
Reply With Quote
 
Diez B. Roggisch
Guest
Posts: n/a
 
      05-19-2009
Jack Trades wrote:

> On May 19, 3:53Â*am, Lawrence D'Oliveiro <l...@geek-
> central.gen.new_zealand> wrote:
>> In message <ac63e27e-2dd9-4c27-ace0-
>>
>> d9e205be7...@s31g2000vbp.googlegroups.com>, Jack Trades wrote:
>> > On May 19, 12:26 am, Lawrence D'Oliveiro <l...@geek-
>> > central.gen.new_zealand> wrote:

>>
>> >> In message <2904e7de-0a8d-4697-9c44-

>>
>> >> c83bb5319...@s31g2000vbp.googlegroups.com>, Jack Trades wrote:
>> >> > Originally I had the 'data' directory in the same directory as the
>> >> > cgi scripts and was using os.system("svn commit"), however I kept
>> >> > running into weird bugs with this method.

>>
>> >> What bugs?

>>
>> > I'm not 100% sure, but I think it had to do with executable
>> > permissions on the cgi scripts.

>>
>> Possibly your CGI scripts are running as some user like "nobody", which
>> doesn't have the right access to the files/directories. Changing APIs
>> won't help here.

>
> Thanks for the help, I'll have to look into that further. If that is
> the case, would setuid be appropriate here? Or is there a better way
> to give the script the appropriate permissions?
> The only thing that baffles me is that the script works before a
> commit and only sometimes after a commit, if it were an access problem
> wouldn't it fail before the commit as well?


I have had many troubles with SVN + permissions.

My recipe is the following:

- create (or use) a "subversion"-group
- make all users (including e.g. www-data) that shall access the SVN
members of this group
- chown -R the svn-repository so that it belongs to this group
- chmod g+s -R to the svn-repository, so that the sticky group bit is set.

THis solves the problems for me usually.

Diez
 
Reply With Quote
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      05-20-2009
In message <5f7f9840-0e17-48fb-acf9->, Jack Trades wrote:

> On May 19, 3:53 am, Lawrence D'Oliveiro <_zealand> wrote:
>
>> Possibly your CGI scripts are running as some user like "nobody", which
>> doesn't have the right access to the files/directories. Changing APIs
>> won't help here.

>
> If that is the case, would setuid be appropriate here?


You mean suexec? Certainly, yes.

 
Reply With Quote
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      05-20-2009
In message <>, Diez B. Roggisch wrote:

> I have had many troubles with SVN + permissions.


I create a custom captive user to own write access to the repository, with
access only to keys belonging to authorized users via svn+ssh. Problem
solved.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free Online Subversion Training - All About Subversion Hook Scripts george.powell@wandisco.com Java 0 05-12-2010 09:43 AM
Free Online Subversion Training - Introduction to Subversion forDevelopers george.powell@wandisco.com Java 5 04-30-2010 02:57 AM
Commit emails for RubyForge Subversion projects Tom Copeland Ruby 2 02-27-2006 07:13 PM
Cannot invoke commit when AutoCommit mode is set to true Maruda Java 1 12-31-2005 04:58 AM
Connection auto commit - No begin? =?ISO-8859-1?Q?Thomas_Gagn=E9?= Java 1 11-19-2003 02:22 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57