我正在尝试显示一个使用烧瓶和ansi2html的ansible-playbook的输出,它输出的结果很好,除了它没有得到任何颜色,只是黑色上的白色。
对于flask的世界来说,这是相当新的,这很好,但它只是需要额外的一点,对于任何指针都很高兴,包括ansi2html之外的其他东西。
下面是特定路由的代码块。
@app.route("/resetprovideo/")
def resetprovideo():
conv = Ansi2HTMLConverter(inline=True)
file = request.args.get('file')
folder = request.args.get('folder')
files = []
for item in os.listdir(folder):
if item.endswith(".tune"):
files.append(item)
try:
if file not in files:
raise ValueError("Error Filename Incorrect!")
except ValueError as err:
return "An Error has occured ... {}".format(err)
else:
def runit():
script = './reset_provideo.sh '
cmd = script + file
session = subprocess.Popen([cmd],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
universal_newlines = True)
for line in iter(session.stdout.readline, ''):
yield conv.convert(line.rstrip()
session.communicate()
exit_code = session.wait()
if int(exit_code) == 0:
exit_code = 'Successfully Completed!'
else:
exit_code = 'Somthing Went Wrong -- rc = ' + str(exit_code)
yield exit_code
return Response(runit(), mimetype='text/html')
如上所述,这是可行的,它只在黑色背景上显示白色文本。
提前感谢
哑光
发布于 2019-07-18 20:41:06
所以事实证明它一直在传递颜色,这不是来自ansible的颜色。
设置配置项
force_color = 1
答对了,我们有颜色了。
https://stackoverflow.com/questions/57101593
复制相似问题