从烧瓶中捕获 git 输出
catch git output from flask
我正在尝试推出一个 quickie flask 应用程序,以从某个存储库中获取 git 统计数据供同事查看。
import os, sys
from flask import Flask, Response
app = Flask(__name__)
@app.route('/git')
def zooi():
out = os.popen('git -C /mygitrepo status').read()
return Response(out, mimetype='text/html')
但是去 http://127.0.0.1:5000/git 没有给出任何输出,也没有错误所以 git 被发现并启动。
这确实显示输出:
out = os.popen('echo test').read()
还有这个:
out = os.popen('gitxxx status').read()
发出:
'gitxxx' is not recognized as an internal or external command
如何从 python / flask 捕获 git 的输出?
这个在 windows 顺便说一句
正在与 subprocess.check_output 合作:
m = subprocess.check_output('git status', shell=False)
注意shell必须设置为False
我正在尝试推出一个 quickie flask 应用程序,以从某个存储库中获取 git 统计数据供同事查看。
import os, sys
from flask import Flask, Response
app = Flask(__name__)
@app.route('/git')
def zooi():
out = os.popen('git -C /mygitrepo status').read()
return Response(out, mimetype='text/html')
但是去 http://127.0.0.1:5000/git 没有给出任何输出,也没有错误所以 git 被发现并启动。 这确实显示输出:
out = os.popen('echo test').read()
还有这个:
out = os.popen('gitxxx status').read()
发出:
'gitxxx' is not recognized as an internal or external command
如何从 python / flask 捕获 git 的输出?
这个在 windows 顺便说一句
正在与 subprocess.check_output 合作:
m = subprocess.check_output('git status', shell=False)
注意shell必须设置为False