def _initialize(self, ctx): if self._initialized: return if ctx.obj is None: ctx.obj = OctoPrintContext() # initialize settings and plugin manager based on provided # context (basedir and configfile) from octoprint import init_settings, init_pluginsystem, FatalStartupError try: self.settings = init_settings( get_ctx_obj_option(ctx, "basedir", None), get_ctx_obj_option(ctx, "configfile", None)) self.plugin_manager = init_pluginsystem( self.settings, safe_mode=get_ctx_obj_option(ctx, "safe_mode", False)) except FatalStartupError as e: click.echo(e.message, err=True) click.echo( "There was a fatal error initializing the settings or the plugin system.", err=True) ctx.exit(-1) # fetch registered hooks self.hooks = self.plugin_manager.get_hooks("octoprint.cli.commands") logging.basicConfig( level=logging.DEBUG if ctx.obj.verbosity > 0 else logging.WARN) self._initialized = True
def _initialize(self, ctx): if self._initialized: return click.echo("Initializing settings & plugin subsystem...") if ctx.obj is None: ctx.obj = OctoPrintContext() # initialize settings and plugin manager based on provided # context (basedir and configfile) from octoprint import init_settings, init_pluginsystem, FatalStartupError try: self.settings = init_settings(get_ctx_obj_option(ctx, "basedir", None), get_ctx_obj_option(ctx, "configfile", None)) self.plugin_manager = init_pluginsystem(self.settings, safe_mode=get_ctx_obj_option(ctx, "safe_mode", False)) except FatalStartupError as e: click.echo(e.message, err=True) click.echo("There was a fatal error initializing the settings or the plugin system.", err=True) ctx.exit(-1) # fetch registered hooks self.hooks = self.plugin_manager.get_hooks("octoprint.cli.commands") logging.basicConfig(level=logging.DEBUG if ctx.obj.verbosity > 0 else logging.WARN) self._initialized = True
def _initialize(self, ctx): if self._initialized: return click.echo("Initializing settings & plugin subsystem...") if ctx.obj is None: ctx.obj = OctoPrintContext() logging_config = dict_merge( LOGGING_CONFIG, { "root": { "level": logging.DEBUG if ctx.obj.verbosity > 0 else logging.WARNING } }, ) logging.config.dictConfig(logging_config) # initialize settings and plugin manager based on provided # context (basedir and configfile) from octoprint import FatalStartupError, init_pluginsystem, init_settings try: self.settings = init_settings( get_ctx_obj_option(ctx, "basedir", None), get_ctx_obj_option(ctx, "configfile", None), overlays=get_ctx_obj_option(ctx, "overlays", None), ) self.plugin_manager = init_pluginsystem( self.settings, safe_mode=get_ctx_obj_option(ctx, "safe_mode", False)) except FatalStartupError as e: click.echo(str(e), err=True) click.echo( "There was a fatal error initializing the settings or the plugin system.", err=True, ) ctx.exit(-1) # fetch registered hooks self.hooks = self.plugin_manager.get_hooks("octoprint.cli.commands") self._initialized = True
def cli(ctx): """Basic config manipulation.""" logging.basicConfig( level=logging. DEBUG if get_ctx_obj_option(ctx, "verbosity", 0) > 0 else logging.WARN) try: ctx.obj.settings = init_settings( get_ctx_obj_option(ctx, "basedir", None), get_ctx_obj_option(ctx, "configfile", None), overlays=get_ctx_obj_option(ctx, "overlays", None), ) ctx.obj.plugin_manager = init_pluginsystem( ctx.obj.settings, safe_mode=get_ctx_obj_option(ctx, "safe_mode", False)) except FatalStartupError as e: click.echo(str(e), err=True) click.echo( "There was a fatal error initializing the settings manager.", err=True) ctx.exit(-1)
def _initialize(self, ctx): if self._initialized: return if ctx.obj is None: ctx.obj = OctoPrintContext() # initialize settings and plugin manager based on provided # context (basedir and configfile) from octoprint import init_settings, init_pluginsystem, FatalStartupError try: self.settings = init_settings(ctx.obj.basedir, ctx.obj.configfile) self.plugin_manager = init_pluginsystem(self.settings, safe_mode=ctx.obj.safe_mode) except FatalStartupError as e: click.echo(e.message, err=True) click.echo("There was a fatal error initializing the settings or the plugin system.", err=True) ctx.exit(-1) # fetch registered hooks self.hooks = self.plugin_manager.get_hooks("octoprint.cli.commands") self._initialized = True