def script_xml(scrname): global dir_scripts acl = get_ACL(scrname) if acl == None: return ("NOT FOUND", 404, {}) else: log(4, "running script_json() ...") if current_user.has_groups(acl): try: args = decode_xml(request.data) (code, out, err) = run_script(dir_scripts, scrname, args) res = {"response": {"code": code, "out": out, "err": err}} log(4, "result = " + dict2str(res)) if code == 0: log(4, out) return make_response(encode_xml(res), 200) else: log(3, err) return make_response(encode_xml(res), 200) except Exception as err: log(1, str(err)) return ("Internal Server Error", 500, {}) else: return ("FORBIDDEN", 403, {})
def generate(location): ret, out, err = scripts.run_script(location, 'answerfile') if ret != 0: raise AnswerfileError, "Generator script failed:\n\n%s" % err try: xmldoc = xml.dom.minidom.parseString(out) except: raise AnswerfileError, "Generator script returned incorrectly formatted output." return Answerfile(xmldoc = xmldoc)
def generate(location): ret, out, err = scripts.run_script(location, 'answerfile') if ret != 0: raise AnswerfileException("Generator script failed:\n\n%s" % err) try: xmldoc = xml.dom.minidom.parseString(out) except: raise AnswerfileException("Generator script returned incorrectly formatted output.") return Answerfile(xmldoc)
def script_form(scrname): global dir_scripts acl = get_ACL(scrname) if acl == None: return ("NOT FOUND", 404, {}) else: log(4, "running script_form() ...") if current_user.has_groups(acl): log(4, request.args) (code, out, err) = run_script(dir_scripts, scrname, request.args) if code == 0: log(1, out) return make_response(str(code) + '\n' + out, 200) else: return make_response(str(code) + '\n' + err, 200) log(3, err) else: return ("FORBIDDEN", 403, {})
from scripts import run_script if __name__ == "__main__": run_script()