FileNotFoundError:[WinError 2] python 3.4 post commit hook

时间:2015-04-02 17:40:40

标签: python windows visualsvn-server

processCommit.py脚本如下所示:

cmd = 'C:\Program Files\VisualSVN Server\bin\svnlook changed %s -r %s' %   (repo, rev)
Line 15 -->**changed = subprocess.Popen(cmd,stdout=subprocess.PIPE).communicate()[0]**
cmd = 'C:\Program Files\VisualSVN Server\bin\svnlook info %s -r %s' % (repo, rev)

提交后我收到的错误:

Error: post-commit hook failed (exit code 1) with output:  
Error: Traceback (most recent call last):  
Error:   File "D:\Repositories\IapAdmin\hooks\processCommit.py", line 15, in <module>  
Error:     changed = subprocess.Popen(cmd,stdout=subprocess.PIPE).communicate()[0]  
Error:   File "C:\Python34\lib\subprocess.py", line 859, in __init__  
Error:     restore_signals, start_new_session)  
Error:   File "C:\Python34\lib\subprocess.py", line 1112, in _execute_child  
Error:     startupinfo)  
Error: FileNotFoundError: [WinError 2] The system cannot find the file specified  

1 个答案:

答案 0 :(得分:1)

swachand.jambhulkar@pers.state.or.us附近添加引号:

session.sendmail('swachand.jambhulkar@pers.state.or.us', 'swachand.jambhulkar@pers.state.or.us', msg.as_string())

<强>更新

cmd = 'C:\Program Files\VisualSVN Server\bin\svnlook changed %s -r %s' % (repo, rev)
changed = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] # line 15
cmd = 'C:\Program Files\VisualSVN Server\bin\svnlook info %s -r %s' % (repo, rev)

不使用\作为路径,而是使用/

cmd = 'C:/Program Files/VisualSVN Server/bin/svnlook changed %s -r %s' % (repo, rev)