使用github webhooks,我希望能够将任何更改提取到远程开发服务器.目前,在适当的目录中,git pull获取需要进行的任何更改.但是,我无法弄清楚如何从Python中调用该函数.我尝试过以下方法:
import subprocess
process = subprocess.Popen("git pull", stdout=subprocess.PIPE)
output = process.communicate()[0]
Run Code Online (Sandbox Code Playgroud)
但这会导致以下错误
回溯(最近调用最后一次):文件"",第1行,在文件"/usr/lib/python2.7/subprocess.py",第679行,在 init errread,errwrite)文件"/ usr/lib/python2. 7/subprocess.py",第1249行,在_execute_child中引发child_exception OSError:[Errno 2]没有这样的文件或目录
有没有办法可以在Python中调用这个bash命令?
我一直试图了解一段时间,现在subprocess.call和之间的区别是什么subprocess.run.我知道最后一个是Python 3.5上的新内容,两者都基于subprocess.Popen,但我还不能理解其中的差异.
我想写一个程序,它将克隆远程git存储库,然后做一堆其他的东西.问题是'git clone'要求输入密码.当我打开stdin/out/err到'git clone'的管道时,它不起作用,因为它在下面运行git-remote-http,提示在TTY上输入密码.
我想从我的程序中传递密码.我在子进程中使用Python和Popen.下面的代码没有wotk.
Popen(['git', 'clone', 'https://my.git.repo/repo.git'], shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE)
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我是Python和Git的新手.我在写一个Python脚本它需要做同样的动作,通过从我的Linux服务器上的工作区运行以下命令的Git做的过程.(即/ local/mnt/workspace /)
git clone git://git.xyz.com/platform/manifest.git -b jb_2.5
Run Code Online (Sandbox Code Playgroud)
我尝试使用Fab库但是没有安装模块fabric.api所以我无法继续.也,
import git
git.Git().clone("git://git.xyz.com/platform/manifest.git") 
Run Code Online (Sandbox Code Playgroud)
没用.
还有其他解决办法吗?很感激帮助.谢谢.