On Mon, Aug 25, 2008 at 8:25 AM, John Peacock <
john.peacock_at_havurah-software.org> wrote:
> Robert Dailey wrote:
>
>> I tried your hints but I'm still not getting anything. I'm assuming
>> the errors will appear during the commit process on the client,
>> however I have seen no errors.
>>
>
> Please read (and follow) my posting here:
>
> http://svn.haxx.se/users/archive-2007-10/0498.shtml
>
> on developing hook scripts. The most important step is #3 (see the
> paragraph with the string "DON'T SKIP THIS STEP!" for why). You should test
> your proposed post-commit hook outside of Subversion itself, because this is
> the only sure-fired way to make sure that the script itself works. Only
> once you have confirmed that the script fires and does what you think it
> should do can you hope to have it run from Subversion...
So, I ran the python script from the command line as suggested by John, and
it worked just fine. My next step was to setup some minimal file logging in
the post commit script, however I'm finding that the script fails when run
by subversion because the open() function in python does not have sufficient
privileges, for some reason. However I can run this manually from the
command line and the open() function succeeds.
So, as a second option, I attempted to raise an exception in my post-commit
script that simply displayed the user currently running the process. The
user should be "svn", but I wanted to make sure. However, the script fails
yet again saying the following:
Warning: post-commit hook failed (exit code 1) with output:
Warning: Traceback (most recent call last):
Warning: File "/srv/svn/repo/www/hooks/post-commit", line 6, in <module>
Warning: raise Exception( os.getlogin() )
Warning: OSError: [Errno 22] Invalid argument
It says "Invalid Argument" right now, but I ran this manually and the
os.getlogin() converted to a string just fine. I'm thinking this has
something to do with my environment not being setup correctly when the
post-commit script is run by subversion. Below is my most recent post-commit
script:
#------------------------------------------
#!/usr/bin/env python
import sys
import os
from subprocess import call
raise Exception( os.getlogin() )
logfile = open( "post-commit-log", "w+b" )
sys.stdout = logfile
sys.stderr = logfile
#_repos = sys.argv[1]
#_rev = sys.argv[2]
call( ["/usr/bin/svn", "update", "--non-interactive", "/srv/http/website"] )
exit( 1 )
#------------------------------------------
As you can see, I'm raising an "Exception", which should display the current
login username, but this fails when running from subversion. Is there more I
must do to initialize the environment so python runs properly? This may not
be an appropriate question for this mailing list, so in the meantime I'll
seek out information elsewhere, but I'm hoping someone here might know a
thing or two. Thanks for everyone's continued help.
Received on 2008-08-25 18:29:05 CEST