我有以下代码作为 get_status.py
#!/usr/bin/env python
from cgi import escape
from flup.server.fcgi import WSGIServer
import commands
import subprocess
def do_get_status():
cmd = """/usr/bin/heat --os-username admin --os-password admin --os-tenant-name admin --os-auth-url http://ipaddress:35357/v2.0/ stack-show demo_stack"""
status, out = commands.getstatusoutput(cmd)
return "<pre>" + str(out) + "</pre>"
def app(environ, start_response):
# initialise and login to the website
#test = testpost.cookie(target_url,username, password)
qs = environ['QUERY_STRING']
result = do_get_status()
start_response('200 OK', [('Content-Type', 'text/html')])
return result
WSGIServer(app).run()
但是当我做http://myserver/cgi-bin/get_status.py我得到的输出是
Unable to establish connection to http://ipaddress:35357/v2.0/tokens
该 python 脚本在 apache cgi-bin 中运行。两天前它工作得很好,但现在它突然停止工作了。如果我接受命令并在命令行上运行它,我会得到预期的结果。我什至尝试使用 python get_status.py 运行相同的代码,我得到了预期的结果。我无法理解可能是什么问题。