Exemple #1
0
 def __init__(self, config, port=8889):
     super().__init__(config, port)
     self.port = port if port is not None else self.config.messaging.port
     self.sender = sms_sender.get(self.config)
     self.queue = queues.Queue()
     self.scheduler = scheduler.MessageScheduler(
         config=self.config, db=self.db_factory.create(), queue=self.queue)
     self.callbacks = [self.process]
Exemple #2
0
 def __init__(self, config, port=8889):
   super().__init__(config, port)
   self.port = port if port is not None else self.config.messaging.port
   self.sender = sms_sender.get(self.config)
   self.queue = queues.Queue()
   self.scheduler = scheduler.MessageScheduler(
     config=self.config, db=self.db, queue=self.queue)
   print([m.text for m in self.scheduler.messages])
   self.callbacks = [self.process]
Exemple #3
0
 def __init__(self, config, port=8889):
   self.config = config
   self.db = sqlite.SQLiteDB(self.config.db.sqlite_path)
   self.port = port
   self.sender = sms_sender.get_sender(self.config)
   self.queue = queues.Queue()
   self.scheduler = scheduler.MessageScheduler(
     db=self.db,
     queue=self.queue,
     token_encoder=token.TokenEncoder(self.config),
     base_url=self.config.server.base_url,
     max_retries=self.config.scheduler.max_retries,
     reminder_delay=self.config.scheduler.reminder_delay,
     when=self.config.scheduler.ping,
   )
Exemple #4
0
    def setUp(self):
        super().setUp()
        self.config = config.Config('resources/test.toml')
        self.db = store.create_store_for_sqlite_db(self.config)
        self.queue = MockQueue()
        self.scheduler = scheduler.MessageScheduler(self.config, self.db,
                                                    self.queue)

        self.admin = self.db.add_default_admin()
        icuid = self.db.add_icu(self.admin, store.ICU(name='my_icu'))
        self.icu = self.db.get_icu(icuid)

        user = store.User(name='michel', telephone='1234')
        userid = self.db.add_user_to_icu(self.admin, icuid, user)
        self.user = self.db.get_user(userid)
Exemple #5
0
  def __init__(self, config, port=8889, telegram_setup=None):
    sentry.maybe_init_sentry(config, server_name='messaging')
    super().__init__(config, port)
    self.port = port if port is not None else self.config.messaging.port
    self.db = self.db_factory.create()
    self.queue = queues.Queue()
    self.scheduler = scheduler.MessageScheduler(
      config=self.config, db=self.db, queue=self.queue
    )
    self.sender = sender.Sender(self.config, self.db, self.queue)
    self.callbacks = [self.sender.process]

    self.telegram_setup = telegram_setup
    if self.telegram_setup is None:
      self.telegram_setup = integrator.TelegramSetup(
        self.config, self.db, self.scheduler
      )
    self.telegram_setup.setup_fetching(self.callbacks)