在Windows的Subversion挂钩中使用python脚本 [英] Using python scripts in subversion hooks on windows
问题描述
My main goal is to get this up and running.
当我用Tortoise SVN进行提交时,我的钩子被调用,但是当我到达以下行时,它总是退出:Python%〜dp0trac-post-commit-hook.py" -p%TRAC_ENV%" -r %REV%" ||退出5
My hook gets called when I do the commit with Tortoise SVN, but it always exits when I get to this line: Python "%~dp0trac-post-commit-hook.py" -p "%TRAC_ENV%" -r "%REV%" || EXIT 5
如果我尝试用任何简单的Python脚本替换对python脚本的调用,它仍然无法正常工作,因此我假设这是对Python的调用而不是脚本本身的问题.
If I try and replace the call to the python script with any simple Python script it still doesn't work so I'm assuming it is a problem with the call to Python and not the script itself.
我尝试设置PYTHON_PATH变量,还设置%PATH%以包括Python.
I have tried setting the PYTHON_PATH variable and also set %PATH% to include Python.
我已经开始运行,所以Python可以在服务器上运行.
I have trac up and running so Python is working on the server itself.
以下是一些背景信息:
-
Python已安装在Windows服务器上,并且脚本是从本地计算机上调用的,因此
Python is installed on Windows server and script is called from local machine so
如果不存在%TRAC_ENV%退出3
IF NOT EXIST %TRAC_ENV% EXIT 3
和
SET PYTHON_PATH = X:\ Python26 如果不存在%PYTHON_PATH%退出4
SET PYTHON_PATH=X:\Python26 IF NOT EXIST %PYTHON_PATH% EXIT 4
失败,除非我将它们设置为映射的网络驱动器(也就是说,将它们指向X和Y驱动器而不是C和E驱动器)
fail unless I point set them to the mapped network drive (That is point them at X and Y drives not C and E drives)
- 可以从服务器的命令行在任何位置调用Python脚本,而不管驱动器如何,因此应正确设置PATH变量
在外部调用python脚本时似乎存在问题,但不确定如何更改此权限.
Appears to be an issue with calling python scripts externally, but not sure how I go about changing the permissions for this.
谢谢.
推荐答案
请注意以下几点:
- 网络驱动器映射和
subst
映射是特定于用户的.确保 用户帐户存在驱动器 svn服务器所在的位置 正在运行. - subversion钩子脚本为运行
没有任何环境变量
出于安全原因设置,甚至没有
%path%
.称呼 带有 绝对路径,例如c:\python25\python.exe
.
- network drive mappings and
subst
mappings are user specific. Make sure the drives exist for the user account under which the svn server is running. - subversion hook scripts are run
without any environment variables
being set for security reasons, not even
%path%
. Call the python executable with an absolute path, e.g.c:\python25\python.exe
.
这篇关于在Windows的Subversion挂钩中使用python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!