def __init__(self, config): self.config = config self.database = DemoData.get_session(self.config) # Security Email if self.config.security_type == "email": self.mail = DemoMail( host=self.config.mail_host, port=self.config.mail_port, from_mail=self.config.mail_from, user=self.config.mail_user, password=self.config.mail_password, tls=self.config.mail_tls, ) else: self.mail = None # Security Auth if self.config.security_type.startswith('auth_'): path = os.path.join(os.path.dirname(__file__), "auth") mod_name = self.config.security_type auth_mod = __import__( 'auth.'+mod_name, globals(), locals(), fromlist=[mod_name] ) auth_class = getattr(auth_mod, Demo.get_class_name(mod_name)) self.auth = auth_class(self.config.auth) else: self.auth = False # Provider path = os.path.join(os.path.dirname(__file__), "provider") prov_name = 'prov_'+self.config.provider prov_mod = __import__( 'provider.'+prov_name, globals(), locals(), fromlist=[prov_name] ) prov_class = getattr( prov_mod, Demo.get_class_name(self.config.provider) ) self.provider = prov_class(self.config.provider_data)
def cli_entrypoint(): parser = argparse.ArgumentParser() parser.add_argument('-c', help='config file', default='./config.ini') args = parser.parse_args() DemoConfig.config_file = args.c config = DemoConfig() # create table session = DemoData.get_session(config) session.close() logging.basicConfig(level=config.log_level) vacuum = Vacuum() pool = Pool() try: vacuum.start() pool.start() server = ThreadedHTTPServer(('0.0.0.0', config.http_port), Handler) server.serve_forever() except (KeyboardInterrupt, SystemExit): logging.info("Exit signal catched") vacuum.stop = True