def stop_action(self, data):
     logging.info("stop a task")
     taskObj = Task.get_task(data['taskid'])
     taskObj.set_status('stop')
     return json.dumps({
         'code': 'true',
         'res': '',
         'desc': ''
     })
 def change_action(self, data):
     logging.info("change task")
     try:
         taskObj = Task.get_task(data['taskid'])
         if taskObj == None:
             self.res['code'] = 1
             return json.dumps(self.res)
         taskObj.set_qps(data['qps'])
         return json.dumps({'code': 'true', 'res': '', 'desc': ''})
     except:
         return sys.exc_info()
 def queryTaskAgent_action(self, data):
     logging.info("query task agent")
     try:
         taskObj = Task.get_task(data['taskid'])
         if taskObj == None:
             return json.dumps({
                 'code': 'false',
                 'res': '',
                 'desc': 'taskid not found'
             })
         res = taskObj.get_all_agent()
         hosts = []
         for agent in res:
             hosts.append(agent.__dict__)
         return json.dumps({'code': 'true', 'res': hosts, 'desc': ''})
     except:
         return sys.exc_info()
 def queryTask_action(self, data):
     logging.info("query task")
     try:
         taskObj = Task.get_task(data['taskid'])
         if taskObj == None:
             return json.dumps({
                 'code': 'false',
                 'res': '',
                 'desc': 'taskid not found'
             })
         return json.dumps({
             'code': 'true',
             'res': taskObj.__dict__,
             'desc': ''
         })
     except:
         return sys.exc_info()