1
votes

I've setup a post commit script found at http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook to associate changesets with tickets

When I try to commit, I get the following error

'post-commit' hook failed with error output:
File "/var/www/svn/repo/hooks/trac-post-commit-hook", line 101
(options, args) = parser.parse_args(sys.argv[1:])
^ SyntaxError: invalid syntax

I'm running Python 2.4.3 on CentOS.

I'm not familiar with Python, so I can't really tell whats happening here and no one seems to have had this issue before (according to Google).

I was hoping someone here would know what's going on.

Thanks in advance.

EDIT:

If it helps, here is my post-commit script

REPOS="$1"
REV="$2"

LOG='/usr/bin/svnlook log -r $REV $REPOS'
AUTHOR='/usr/bin/svnlook author -r $REV $REPOS'
TRAC_ENV="/var/www/trac/[xxx]/"
TRAC_URL='http://trac.[xxx].com/'


/usr/bin/python /var/www/svn/repo/hooks/trac-post-commit-hook -p "$TRAC_ENV" -r "$REV" -u "$AUTHOR" -m "$LOG" -s "$TRAC_URL"

2

2 Answers

3
votes

May be you have space or tab before (options,args)? may be like this.

>>> (options, args) = parser.parse_args(sys.argv[1:])
>>> # this is fine
>>>
>>>  (options, args) = parser.parse_args(sys.argv[1:])
  File "<stdin>", line 1
    (options, args) = parser.parse_args(sys.argv[1:])
    ^
SyntaxError: invalid syntax
>>>
2
votes

Wow, that is weird. The line is definitely valid syntax, and the Python version should also not be a problem since the script's copyright statement has the same year Python 2.4 was released in. Do you have multiple Python installations on your machine? If so, can you check whether /usr/bin/env python returns the correct one?