Exemple #1
0
 def task(self, args):
     try:
         self.login(args)
         return self.task_impl(args)
     except Exception as e:
         tb = traceback.format_exc()
         raise TaskError(str(e) + '\n' + tb, 'st2.task.base/task_exception')
Exemple #2
0
 def task(self, args):
     self.debug('a debugging statement')
     self.debug('another debugging statement')
     raise TaskError(
         'a task error',
         'mytask/failed',
         { 'debug': self.debug_statements }
     )
Exemple #3
0
 def exec_cmd(self, cmd, error_msg):
     result = {}
     try:
         stdout = subprocess.check_output(cmd,
                                          stderr=subprocess.STDOUT,
                                          env=self.env)
         result.update(self.parse_output(stdout))
     except subprocess.CalledProcessError as e:
         tb = traceback.format_exc()
         raise TaskError(("Could not {}: {} \n {}\n {}".format(
             error_msg, str(e), e.output, tb)),
                         'st2.task.base/subprocess_error')
     except Exception as e:
         tb = traceback.format_exc()
         raise TaskError(
             ("Could not {}: {}\n {}".format(error_msg, str(e), tb)),
             'st2.task.base/exec_exception')
     return result
Exemple #4
0
 def task(self, args):
     raise TaskError('a task error', 'mytask/failed',
                     {'any': 'thing'})