Example #1
0
 def __call__(self, handler, message):
     message_text = utils.canonicalize_text(message.body.text)
     ok_responses = []
     ok_responses.extend(self.kill_responses)
     ok_responses.extend(self.int_responses)
     ok_responses.extend(self.term_responses)
     if (handler.state in ('EXECUTING', 'EXECUTING_KILLED',
                           'EXECUTING_TERM', 'EXECUTING_INTERRUPT') and
             message_text in ok_responses):
         replier = functools.partial(message.reply_text,
                                     threaded=True, prefixed=False,
                                     thread_ts=handler.message.body.ts)
         if message_text in self.kill_responses:
             handler.change_state('EXECUTING_KILLED')
             how_stopped = 'killed (via `SIGKILL`)'
         if message_text in self.int_responses:
             handler.change_state('EXECUTING_INTERRUPT')
             how_stopped = 'interrupted (via `SIGINT`)'
         else:
             handler.change_state('EXECUTING_TERM')
             how_stopped = 'terminated (via `SIGTERM`)'
         replier("Playbook run will hopefully be"
                 " %s soon." % how_stopped)
         return True
     return False
Example #2
0
 def __call__(self, handler, message):
     message_text = utils.canonicalize_text(message.body.text)
     if message_text in self.state_responses:
         replier = functools.partial(message.reply_text,
                                     threaded=True, prefixed=False,
                                     thread_ts=handler.message.body.ts)
         replier("The handler is in `%s` state." % (handler.state))
         return True
     return False
Example #3
0
 def __call__(self, handler, message):
     message_text = utils.canonicalize_text(message.body.text)
     if message_text == 'console':
         if handler.build is None or handler.job is None:
             return False
         console_out = handler.build.get_console()
         console_out = _format_build_console(console_out,
                                             line_limit=CONSOLE_LINES,
                                             add_header=False)
         replier = functools.partial(message.reply_text,
                                     threaded=True,
                                     prefixed=False,
                                     thread_ts=handler.message.body.ts)
         replier(console_out)
         return True
     return False
Example #4
0
 def __call__(self, handler, message):
     message_text = utils.canonicalize_text(message.body.text)
     if message_text in self.cancel_responses:
         handler.change_state('CONFIRMED_CANCELLED')
         return True
     who_confirmed = (message.body.user_name, message.body.user_id)
     if self._is_jfdi(message_text):
         self.confirms_forced.add(who_confirmed)
         handler.change_state('CONFIRMED_FORCED')
         return True
     replier = functools.partial(
         message.reply_text, threaded=True, prefixed=True,
         thread_ts=handler.message.body.ts)
     if message_text in self.go_responses:
         what = self.confirms_what
         prior_message_user_name = handler.message.body.user_name
         message_user_name = message.body.user_name
         if ((who_confirmed in self.confirms or
                 # Disallow self-signoffs...
                 message_user_name == prior_message_user_name) and
                 not self.confirm_self_ok):
             authorizer = handler.handles_what.get('authorizer')
             if authorizer is not None:
                 replier("Please get another member"
                         " that satisfies authorizer `%s` to signoff"
                         " on this %s." % (authorizer.pformat(handler.bot),
                                           what))
             else:
                 replier("Please get another member"
                         " to signoff on this %s." % (what))
         else:
             self.confirms.add(who_confirmed)
             if len(self.confirms) >= self.confirms_needed:
                 handler.change_state("CONFIRMED")
     elif (message_text in self.check_responses and
             self.check_func is not None):
         replier(self.check_func())
     else:
         ok_responses = list(self.cancel_responses)
         ok_responses.extend(self.go_responses)
         if self.check_func is not None:
             ok_responses.extend(self.check_responses)
         ok_responses.sort()
         replier("Unexpected confirmation response, please respond"
                 " with one of %s." % (", ".join(ok_responses)))
     return True
Example #5
0
 def __call__(self, handler, message):
     message_text = utils.canonicalize_text(message.body.text)
     if message_text in ['stop', 'abort', 'cancel']:
         if handler.build is None or handler.job is None:
             return False
         replier = functools.partial(message.reply_text,
                                     threaded=True,
                                     prefixed=False,
                                     thread_ts=handler.message.body.ts)
         replier("Build %s is being requested"
                 " to stop." % handler.build.number)
         was_stopped = handler.build.stop(before_poll=True)
         if was_stopped:
             replier("Build %s has been" " stopped." % handler.build.number)
         else:
             replier("Build %s has *not* been"
                     " stopped (is it still"
                     " running?)" % handler.build.number)
         return True
     return False
Example #6
0
 def __call__(self, handler, message):
     message_text = utils.canonicalize_text(message.body.text)
     if message_text in self.cancel_responses:
         handler.change_state("CANCELLED")
         return True
     return False