Trac 提交后脚本出现问题(SyntaxError:语法无效)

发布于 2024-08-17 05:29:45 字数 1052 浏览 4 评论 0原文

我已经设置了一个提交后脚本,位于 http:// trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook 将变更集与票证关联

当我尝试提交时,出现以下错误

“提交后”挂钩失败并出现错误输出:
文件“/var/www/svn/repo/hooks/trac-post-commit-hook”,第 101 行
(选项, args) = parser.parse_args(sys.argv[1:])
^ 语法错误:语法无效

我在 CentOS 上运行 Python 2.4.3。

我对 Python 不熟悉,所以我无法真正判断这里发生了什么,而且之前似乎没有人遇到过这个问题(根据 Google 的说法)。

我希望这里有人知道发生了什么事。

提前致谢。

编辑:

如果有帮助,这是我的提交后脚本

REPOS=“$1”
REV="$2"

LOG='/usr/bin/svnlook log -r $REV $REPOS'
AUTHOR='/usr/bin/svnlook 作者 -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”

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"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

度的依靠╰つ 2024-08-24 05:29:45

可能是你前面有空格或制表符(选项,参数)?可能是这样的。

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

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
>>>
铃予 2024-08-24 05:29:45

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

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文