Esempio n. 1
0
    def on_actions(self, actions):
        #self.maybe_go_insane()
        if not self.sane:
            return

        log.info(self.log('actions: %s' % actions))
        action = find_first_common_element(self.actions_to_do, actions)

        if action == 'dial':
            if self.dial_counter >= 1:
                return
            self.dial_counter += 1

        if action == 'transfer':
            if self.transfer_counter >= 1 or len(CallHandler.lines_calls) < 2:
                return
            self.transfer_counter += 1

        if self.dial_counter > 50:
            print 'OVERFLOW========================================='
            import sys; sys.exit(1)

        if action is not None:
            log.info(self.log('generated call action: %s' % action))
            if action == 'number':
                self.call_action('onhook', [])
                self.call_action('offhook', [])
            self.call_action(action, generate_params(action, self.params_generators))
            if action == 'number':
                yield sleep()
Esempio n. 2
0
 def run(self):
     self.running = True
     for action in takewhile(lambda a: self.running, self.action_generator):
         log.info(self.log('action %s' % action))
         action = self.maybe_override_action(action)
         params = generate_params(action, self.params_generators)
         yield self.fire_action(action, params)
         self.last_action = action
Esempio n. 3
0
 def on_dialtone(self, tone):
     #self.maybe_go_insane()
     if not self.sane:
         return
     if tone != 'inside':
         return
     if self.got_tone:
         return
     self.got_tone = True
     log.info(self.log('dialtone'))
     self.action_cb('number', generate_params('correct_number', self.params_generators), self.line, self.id)