def task_run(idnum, request): while 1: try: task = Task.objects.get(id=idnum) except: continue break if task.status != 'executed' and task.status != 'running' and task.status != 'NULL': hosttag = task.dbtag sql = task.sqltext mycreatetime = task.create_time incept.log_incep_op(sql, hosttag, request, mycreatetime) status = 'running' task.status = status task.operator = request.user.username task.update_time = datetime.datetime.now() task.save() db_type_record = func.get_dbtype_bydbtag(hosttag) dbtype_flag = str(db_type_record[0][0]) if dbtype_flag == 'mysql': process_runtask.delay(hosttag, sql, task) #process_runtask(hosttag, sql, task) elif dbtype_flag == 'Oracle': useraccount = request.user.username ipaddr = func.get_client_ip(request) process_runtask_oracle.delay(hosttag, sql, task, useraccount, ipaddr) #process_runtask_oracle(hosttag, sql, task, useraccount, ipaddr) #delayoracle #process_runtask_oracle(hosttag, sql, task, useraccount, ipaddr) return '' elif task.status == 'NULL': return 'PLEASE CHECK THE SQL FIRST' else: return 'Already executed or in running'
def task_run(idnum, request): while 1: try: task = Task.objects.get(id=idnum) except: continue break if task.status != 'executed' and task.status != 'running' and task.status != 'NULL': hosttag = task.dbtag sql = task.sqltext mycreatetime = task.create_time incept.log_incep_op(sql, hosttag, request, mycreatetime) status = 'running' task.status = status task.update_time = datetime.datetime.now() task.save() process_runtask.delay(hosttag, sql, task) return '' elif task.status == 'NULL': return 'PLEASE CHECK THE SQL FIRST' else: return 'Already executed or in running'
def task_run(idnum,request): while 1: try: task = Task.objects.get(id=idnum) except: continue break if task.status!='executed' and task.status!='running' and task.status!='NULL': hosttag = task.dbtag sql = task.sqltext mycreatetime = task.create_time incept.log_incep_op(sql,hosttag,request,mycreatetime) status='running' task.status = status task.update_time = datetime.datetime.now() task.save() process_runtask.delay(hosttag,sql,task) return '' elif task.status=='NULL': return 'PLEASE CHECK THE SQL FIRST' else: return 'Already executed or in running'