使用 github webhooks,我希望能够将任何更改拉到远程开发服务器。目前,当在适当的目录中时,git pull
获取需要进行的任何更改。但是,我不知道如何从 Python 中调用该函数。我尝试了以下方法:
import subprocess
process = subprocess.Popen("git pull", stdout=subprocess.PIPE)
output = process.communicate()[0]
但这会导致以下错误
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
有没有办法可以从 Python 中调用这个 bash 命令?