Exemple #1
0
 def start (self):
     self.config      = Configuration.get_dictionary()
     if self.config.__len__() < 1: raise Exception, "Need configuration fixture"
     for conf in self.config:
         try:
             x   = eval(self.config[conf])
             if x.__class__ == bool:
                 self.config[conf] = x
         except:
             pass
            
     # import carrier class from simpleoperator
     self.carrier    = eval("%s()" % self.config['carrier'])
     
     # storing backend for USSD interaction
     self.backend    = self._router.backends[-1]
     
     # set alias for logs
     self.me         = self.config['local_alias']
     
     self.keywords   = []
     self.keywords.append({'id': self.BALANCE_ID, 'keyw': self.config['keyword_balance']})
     self.keywords.append({'id': self.TOPUP_ID, 'keyw': self.config['keyword_topup']})
     
     # triggers initialization
     try:
         self.balance_allow  = import_function(self.config['balance_allow_helper'])
     except:
         self.balance_allow  = None
     try:
         self.balance_followup   = import_function(self.config['balance_followup'])
     except:
         self.balance_followup   = None
     try:
         self.topup_allow  = import_function(self.config['topup_allow_helper'])
     except:
         self.topup_allow  = None
     try:
         self.topup_followup   = import_function(self.config['topup_followup'])
     except:
         self.topup_followup   = None
     
     # Registering loops
     self.router.call_at(to_seconds(self.config['balance_check_interval']), self.period_balance_check)
     
     self.log    = self._router.log
     pass