def on_failure(self, exc, task_id, args, kwargs, einfo): #self.log.info("[{0}]: FAILURE : {1}".format(task_id, exc)) # SEND FAIL MAIL mail_obj = Mail(mail_type='SYNC_FAIL', exc=exc, task_id=task_id, einfo=einfo) mail_obj.send() self.log.info("[{0}]: SYNC FAIL MAIL SENT".format(task_id))
def on_success(self, retval, task_id, args, kwargs): #self.log.info("[{0}]: SUCCESS : {1}".format(task_id, retval)) # SEND DONE MAIL mail_obj = Mail(mail_type='SYNC_COMPLETE', task_id=task_id, retval=retval) mail_obj.send() self.log.info("[{0}]: SYNC COMPLETE MAIL SENT".format(task_id))
def on_success(self, retval, task_id, args, kwargs): # SEND SPOOL COMPLETE MAIL mail_obj = Mail(mail_type='SPOOL_COMPLETE', task_id=task_id, retval=retval) mail_obj.send() self.log.info("[{0}]: SPOOL COMPLETE MAIL SENT".format(task_id)) pass
def run(self, dep_file_path, cmd): task_id = self.request.id #logger = get_or_create_task_logger(func=sync) # SEND SUBMIT MAIL mail_obj = Mail(mail_type='SYNC_SUBMIT', task_id=task_id) mail_obj.send() self.log.info("[{0}]: SYNC SUBMIT MAIL SENT".format(task_id)) self.log.info("[{0}]: Dep file: {1}".format(task_id, dep_file_path)) self.log.info("[{0}]: Start command: {1}".format(task_id, cmd)) retval = self.exec_cmd(task_id, cmd) self.log.info("[{0}]: Finish command: {1}".format(task_id, cmd)) if retval == 0: #msg = "[{0}]: Sync successful".format(task_id) #self.log.info(msg) return task_id else: # raise an error msg = "[{0}]: Sync failed: {0}".format(task_id) self.log.info(msg) raise TaskException(msg) '''
def send_mail(**kwargs): mail_obj = Mail(**kwargs) mail_obj.send() self.log.info("[{0}]: SYNC FAIL MAIL SENT".format(task_id))