def tryLoad(mn): ''' Load package mn. If it contains __gicdat__ (list of subpackages) load all of these. Otherwise If it includes __all__, load those subpackages. If you write a gicdat madule that contains __all__ in __init__.py, but doesn't use it to point exclusively at sub-packages that should be loaded as blocks (for example because you want to refference individual modules in __all__ so as to support from mypackage import *), then you will need to specify __gicdat__=[], in order to prevent tryLoad from treating these references as additional blocks. ''' try: if mn in MODS: control.report('reloading %s' % mn) reload(MODS[mn]) else: exec "import %s as mod" % mn MODS[mn] = mod if mn in FAILED_LOAD: reload(mod) del (FAILED_LOAD[mn]) if hasattr(MODS[mn], "__gicdat__"): for s in MODS[mn].__gicdat__: tryLoad(mn + "." + s) elif hasattr(MODS[mn], "__all__"): for s in MODS[mn].__all__: tryLoad(mn + "." + s) except: e = sys.exc_info() FAILED_LOAD[mn] = e if mn in MODS: del (MODS[mn]) control.error(e, None, "error loading module %s" % mn) return MODS.get(mn)
def deletereport(): data = request.form.get('reportid') idlist = data.split(';') case = control.report() for i in idlist: print(i) case.deletereport(i) return "编号:%s 的报告删除成功" % data
def reportlist(): # systemname = request.form.to_dict()['systemname'] # print(taskid) if request.method == 'GET': a = control.report() b = a.show(a.reportlist) return jsonify(b) else: systemname = request.form.to_dict()['systemname'] a = control.report(systemname=systemname) b = a.show(a.reportlist) return jsonify(b)
def collect(self, ret, delete, pref='j'): d = gd.Doc() for i, id in enumerate(ret): di = self.get('/doc/%i' % id, ctype=jobs.CTYPE) try: di = jobs.str2d(di) except: raise ValueError('No document in response %s' % di) d['%s%i' % (pref, i)] = di if delete: url = "/doc?" + "&".join(["id=%i" % i for i in delete]) z = self.delete(url) if not self.isok(z): report("WARNING: delete failed: %s" % z) return d
def __call__(self, doc, subset=()): try: d, m = self.gettf()(doc, self.p) for s in m: report(s) dd = doc.subset(subset) if self.o: dd[self.o] = d else: dd = dd.fuse(d) except Exception as e: dd = Doc({'_failed': True, '_traceback': format_exc(e), '_input': doc, '_job': self.todoc()}) return dd
def showreport(): taskid = request.form.to_dict()['taskid'] # print(taskid) a = control.report(taskid) try: b = a.reporthtml() return b except BaseException: return "当前任务未执行完毕"
def downloadreport(): reportid = request.args.get("reportid") # print(caseid) # caseid = 193 a = control.report() b = a.reportpath(reportid) filename = b path = "./static/report/testreport/" # print(b) response = make_response( send_from_directory(path, filename.encode('utf-8').decode('utf-8'), as_attachment=True)) response.headers["Content-Disposition"] = "attachment; filename={}".format(filename.encode().decode('latin-1')) return response
def uploadreport(): # print(request.files) file = request.files['file_data'] # print(file) # print(file.filename) # filename = file.filename.split('.')[0] filetype = file.filename.split('.')[1] a = control.report() if filetype != 'jmx': b = a.savereport(file.filename) if b: app.config['UPLOAD_FOLDER'] = 'D:\\operations_test\\static\\report\\testreport' file.save(os.path.join(app.config['UPLOAD_FOLDER'], file.filename)) return jsonify({'result': '报告导入成功'}) else: return jsonify({'result': '报告名称不符合规范'}) else: return jsonify({'result': '文件格式不正确'})
def register(code): ''' Register additional extension modules. Code may be a list of Python module names, a list of absolute path names, or a zipfile. ''' control.report('oops, blocks.register isnt finished yet')