在Windows的Subversion挂钩中使用python脚本 [英] Using python scripts in subversion hooks on windows

查看:125
本文介绍了在Windows的Subversion挂钩中使用python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主要目标是获得

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.

谢谢.

推荐答案

请注意以下几点:

  • 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆