Trac post commit脚本的问题(SyntaxError:语法无效)

时间:2010-01-07 07:35:02

标签: python svn trac post-commit

我在http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook设置了一个帖子提交脚本,用于将变更集与故障单

相关联

当我尝试提交时,我收到以下错误

'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 个答案:

答案 0 :(得分:3)

可能之前有空格或标签(选项,参数)?可能是这样的。

>>> (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
>>>

答案 1 :(得分:2)

哇,这很奇怪。该行绝对是有效的语法,并且Python版本也应该不是问题,因为脚本的版权声明与Python 2.4发布的年份相同。您的计算机上是否安装了多个Python?如果是,您可以检查/usr/bin/env python是否返回正确的答案吗?