使用github webhooks,我希望能夠對遠程開發服務器進行任何更改。目前,在適當的目錄中,git pull
會得到所需的任何更改。但是,我無法弄清楚如何在Python中調用該函數。我曾嘗試以下:如何從Python內部調用'git pull'?
import subprocess
process = subprocess.Popen("git pull", stdout=subprocess.PIPE)
output = process.communicate()[0]
但是,這會導致以下錯誤
Traceback (most recent call last): File "", line 1, in 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命令的方法嗎?
這是一個重複http://stackoverflow.com/questions/4256107/running-bash-commands-in-python – ceptno 2013-03-09 20:32:16
@Brandon這不是真的,還有很多其他的解決方案,最好的。 – jleahy 2013-03-09 20:34:01
PATH中的'git'可執行文件? – poke 2013-03-09 20:41:54