def get_enabled_store_name(): pname = setting.get_global_setting(_KIND, _KEY) if not pname: pname = 'localfile' if not pname in plugin.get_plugins('store'): return None return pname
def run_command(self, args): gathered_deps = [] for plugin_name in get_plugins(): plugin = __import__(plugin_name[0]) gathered_deps.extend(plugin.Plugin.dependencies) for dep in sorted(list(set(gathered_deps))): print(dep)
def load_config(v_camera, path): if not os.path.exists(path): print(f"File {path} not found") all_config = pickle.load(open(path, "rb")) plugins = get_plugins([]) for plugin in plugins: state = all_config.get(plugin.__class__, None) if state is not None: plugin.load(state) plugins.sort(key=lambda x: x.z_index) v_camera.set_mapping(make_chain_process(plugins))
def run_command(self, args): plugins = get_plugins() try: hq = HeadQuarters() print('Jeeves status:') print('headquarters @{0}'.format(hq.hq)) print('plugins:') for plugin in plugins: print('\t', plugin[0]) if plugin[1]: print('\t' * 2, plugin[1]) except JeevesError: sys.exit('No headquarters found. Create using the "init" plugin')
def register_plugins(self, package): new_plugins = [UserPlugin(self) for UserPlugin in get_plugins(package)] self.plugins += new_plugins for plugin in new_plugins: for (event, handler, priority) in plugin.actions(): self.handlers.setdefault(event, []).append((handler, priority)) for packet in plugin.packets(): existing = self.packets.get(packet.packet_name) if existing is not None: raise ArgumentError('Multiple packets cannot be registered for the same packet name. {} is already registered'.format(inspect.getmodule(existing))) self.packets[packet.packet_name] = packet for plugin in new_plugins: log.info('{} - Registered plugin: {} consuming {}'.format( self.type.upper(), plugin.__module__, [action.event for action in plugin.actions()]) )
def run(outdiv, args, middiv): return state = State() state.plugins = [] for id in [ args.getfirst("input_processor"), args.getfirst("output_processor"), ] + args.getlist("plugin") : cls = plugin.plugin_by_id(id) p = plugin.instantiate_with_state(cls, state) state.plugins.append(p) # uhhhh, this is kind of nonsense.... # get other state out of args... # they're named (pluginid_optionname): xml_out_indent= try: (iproc,) = plugin.get_plugins(["input"], state) except ValueError: outdiv << h.p('No input processor selected.') return False input_text = input_text=args.getvalue("input_text", "") input_text = input_text.replace("\r\n", "\n") try: doc = iproc.parse(input_text) except error.SyntaxError, e: err = "" err += e.message + "\n" err += e.illustrate_position() outdiv << h.pre("Error\n"+err, style="padding: 1em; border:2px solid red;") return False
def set_enabled_store_name(pname): if not pname in plugin.get_plugins('store'): raise IOError('cannot find enabled store.') setting.set_global_setting(_KIND, _KEY, pname)
return False input_text = input_text=args.getvalue("input_text", "") input_text = input_text.replace("\r\n", "\n") try: doc = iproc.parse(input_text) except error.SyntaxError, e: err = "" err += e.message + "\n" err += e.illustrate_position() outdiv << h.pre("Error\n"+err, style="padding: 1em; border:2px solid red;") return False for p in plugin.get_plugins(["transform","analysis"], state): if isinstance(p, plugin.TransformPlugin): doc = p.transform(doc) elif isinstance(p, plugin.AnalysisPlugin): report = p.analyze(doc) d = h.div() d << h.p("Report from %s plugin:" % p.id) d << h.pre(report, style="padding:1em; border:1px solid black;") middiv << d else: raise RuntimeError try: (oproc,) = plugin.get_plugins(["output"], state) except ValueError:
input_text = input_stream.read() debug('cmdline', 'read %d bytes' % len(input_text)) iproc = plugin.get_one_plugin(["parse"], options) try: doc = iproc.parse(input_text) except error.SyntaxError, e: err = "" err += e.message + "\n" err += e.illustrate_position() print >>sys.stderr, err return for p in plugin.get_plugins(["transform"], options): doc = p.transform(doc) for p in plugin.get_plugins(["analyze"], options): report = p.analyze(doc) print "\nReport from %s plugin:" % p.id print report print out_stream = sys.stdout oproc = plugin.get_one_plugin(["serialize"], options) debug('cmdline', 'Output processor=', oproc) oproc.serialize(doc, out_stream)