我有一些代码使用子进程来查看git目录中的日志。在本地django开发环境中执行时,我的代码似乎可以正常工作。然而,一旦部署(使用Apache/mode\wsgi),stdout read()的输出将返回空值。我的开发和生产机器现在是一样的,我还试着确保每个文件都是可读的。在
有人知道为什么Popen在这里部署后不返回任何输出吗?谢谢。在
def getGitLogs(projectName, searchTerm=None, since):
os.chdir(os.path.join(settings.SCM_GIT, projectName))
cmd = "git log --since {0} -p".format(since)
p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
output = p.stdout.read()
### here output comes back as expected in dev environment, but empty in once deployed
return filterCommits(parseCommits(output), searchTerm)
chdir
作为命令的一部分(例如,cd /foo/bar/zoo
)git
所以你的命令将以
cd /foo/bar/zoo && /usr/bin/git log since
结束相关问题 更多 >
编程相关推荐