def configure(self, addon, **kwargs): """ A helper for testing configure methods. Modifies the registered Options object with the given keyword arguments, then calls the configure method on the addon with the updated value. """ if addon not in self.master.addons: self.master.addons.register(addon) with self.options.rollback(kwargs.keys(), reraise=True): if kwargs: self.options.update(**kwargs) else: self.master.addons.invoke_addon_sync(addon, hooks.ConfigureHook(set()))
def loadscript(self): ctx.log.info("Loading script %s" % self.path) if self.ns: ctx.master.addons.remove(self.ns) self.ns = None with addonmanager.safecall(): ns = load_script(self.fullpath) ctx.master.addons.register(ns) self.ns = ns if self.ns: # We're already running, so we have to explicitly register and # configure the addon ctx.master.addons.invoke_addon(self.ns, hooks.RunningHook()) try: ctx.master.addons.invoke_addon( self.ns, hooks.ConfigureHook(ctx.options.keys())) except exceptions.OptionsError as e: script_error_handler(self.fullpath, e, msg=str(e))
def script_run(self, flows: typing.Sequence[flow.Flow], path: mtypes.Path) -> None: """ Run a script on the specified flows. The script is configured with the current options and all lifecycle events for each flow are simulated. Note that the load event is not invoked. """ if not os.path.isfile(path): ctx.log.error('No such script: %s' % path) return mod = load_script(path) if mod: with addonmanager.safecall(): ctx.master.addons.invoke_addon(mod, hooks.RunningHook()) ctx.master.addons.invoke_addon( mod, hooks.ConfigureHook(ctx.options.keys()), ) for f in flows: for evt in eventsequence.iterate(f): ctx.master.addons.invoke_addon(mod, evt)
def mkmaster(self, **opts): o = options.Options(**opts) m = console.master.ConsoleMaster(o) m.addons.trigger(hooks.ConfigureHook(o.keys())) return m
def _configure_all(self, options, updated): self.trigger(hooks.ConfigureHook(updated))