def submit(): # job_info need guid,type,mail,ip job_o = job_han.create_job(request) views.args_han(job_o).submit(request) job_o.save() # send a mail mail_han.send(job_o,'submitted') return jsonify({'guid':job_o.guid})
def submit(): # job_info need guid,type,mail,ip job_info = dict([[x,request.form.get(x)] for x in ['guid','type','mail']]+[['ip',request.remote_addr]]) job_o = job_han.add_by_info(job_info) views.args_han(job_o).submit(request.form) # send a mail mail_han.send(job_o,{'status':'submitted'}) return jsonify({'guid':job_o.guid})
def get_result(): "as an result parser, each call will check daemon running if job un-complete, return _msg if job un-completed" job_o = job_handler().get_by_guid(request.args['guid']) if job_o: if job_o.time_complete: result = args_han(job_o).parse() if result: return jsonify(result) else: return jsonify( {'_msg': { '_type': 'error', 'des': 'data parse error' }}) else: daemon_path = os.path.abspath( os.path.join(g.conf._basedir, g.conf.mconfig['jobs']['daemon_path'])) proc = os.system( 'ps x | awk \'$6 == "%s"{ck=1;exit}END{if(!ck)system("nohup %s &")}\'' % (daemon_path, daemon_path)) wait_list = job_handler().todo_list() return jsonify({ '_msg': { '_type': 'status', 'des': 'your job ranking at %s' % (0 if not wait_list.count() else (job_o.id - job_handler().todo_list().first().id)) } }) else: return jsonify({'_msg': {'_type': 'error', 'des': 'no this job'}})
def get_args(): "get args json of a job to create form" job_o = job_han.get_by_guid(request.args['guid']) if job_o: args = views.args_han(job_o).get() if args: return jsonify(args) else: return jsonify({'_err':'no_job'})
def get_args(): "get args json of a job" job_o = job_han.get_by_guid(request.args['guid']) if job_o: args = views.args_han(job_o).get() if args: return jsonify(args) else: jsonify({'_msg':{'_type':'error','des':'job deleted'}}) else: return jsonify({'_msg':{'_type':'error','des':'no this job'}})
def get_result(): "as an result parser, each call will check daemon running if job un-complete, return _msg if job un-completed" job_o = job_han.get_by_guid(request.args['guid']) if job_o: if job_o.time_complete: result = views.args_han(job_o).parse() if result: return jsonify(result) else: return jsonify({'_err':'parser_err'}) else: job_count = views.daemon_ck() return jsonify({'_msg':'waiting'}) else: return jsonify({'_err':'no_job'})