def run(self,content): #check params #write info into local sqlite obj = ProcessAgentTask() #return task info return obj.run(content)
class TaskContentParse(): """function:parse task content detail ,get need info,execute script, return result,callback task result""" def __init__(self,path,filename): self._path = path self._filename =filename self._process_task_obj = ProcessAgentTask() def run(self): #step-1:read task file content content = self.read_file() if content: result = True info = self._process_task_obj.inner_process_ret(content) else: result = False info = u"[TaskContentParse]read content is null or content parse error." #step-2:execute content return (result,info) def __rename_file(self,str_cmd=""): """""" try: if str_cmd: ret_info =exec_cmd(str_cmd) if ret_info: str_info = "\n".join(ret_info) else: str_info="command already execute,but not return info." else: str_info="command content is null,please check" except Exception,e: log(str(e)) return str_info
def run(self): while not self._stopevent.is_set(): self._cond.acquire() while self._queue.empty(): self._cond.wait() fetch_data = self._queue.get() #process data #update task status self._cond.release() #obj = self._class_obj() obj = ProcessAgentTask() ret_result = obj.run(fetch_data) #add callback result log(str(ret_result)) #self._callback_obj.run(ret_result) #time.sleep sleep_interval = random.randint(0,10) time.sleep(sleep_interval)
def __init__(self,path,filename): self._path = path self._filename =filename self._process_task_obj = ProcessAgentTask()