def register_extensions(self, extensions = []): try: for extension, config in self.config['extensions'].items(): # extension module base string ext_bstr = 'ext.%s' % (extension) # extension core module string ext_cmstr = '%s.%s' % (ext_bstr, extension) # extension module object ext_module = import_module(ext_cmstr) # extension class ext_class = getattr(ext_module, extension.title()) # check if extension is bootable if issubclass(ext_class, Facade): cext_class = getattr(ext_module, '%sExtension' % (extension.title())) ext_class.register(cext_class, config) # register extension commands if exists ext_cmdstr = '%s.%s' % (ext_bstr, 'commands') ext_cmd_module = import_module(ext_cmdstr, pass_errors = True) if ext_cmd_module is not None: self.commandadapter.register_extension(ext_cmd_module, extension) except Exception, e: Log.error(e)
def register_log(self): """ Function registers Log facade using configuration in app.config.<env>. Note: The Log facade will be registered using default configuration if there isn't any 'log' key in app.config.<env>. """ if 'log' in self.config: Log.register(self.config['log']) else: Log.register()
def register_extensions(self, extensions=[]): """ Function registers extensions given extensions list Args ---- extensions (list) : the extensions dict on app.config.<env> Raises ------ Exception: Raises exception when extension can't be loaded properly. """ try: for extension, config in self.config['extensions'].items()): # extension module base string ext_bstr = 'ext.%s' % (extension) # start script ext_sstr = '%s.start' % ext_bstr ext_startmodule = import_module(ext_sstr, pass_errors=True) if ext_startmodule is not None: before = getattr(ext_startmodule, 'before') before(config) # register extension commands if exists ext_cmdstr = '%s.%s' % (ext_bstr, 'commands') ext_cmd_module = import_module(ext_cmdstr, pass_errors=True) if ext_cmd_module is not None: self.commandadapter.register_extension( ext_cmd_module, extension) except Exception as e: print(traceback.format_exc()) Log.error(e)
def register_log(self): if 'log' in self.config: Log.register(log, self.config['log']) else: Log.register(log)
def run(self, app): Log.info('Glim server started on %s environment' % self.args.env) app.start(host = self.args.host, port = self.args.port)
def run(self, app): """Function starts the web server given configuration.""" Log.info('Glim server started on %s environment' % self.args.env) app.start(host=self.args.host, port=self.args.port)