def make_report(app, err): """ Formats a bug report. """ from genesis.plugmgr import PluginLoader pr = '' for p in sorted(PluginLoader.list_plugins().keys()): pr += p + '\n' # Finalize the reported log app.log.blackbox.stop() buf = app.log.blackbox.buffer.split('\n') if len(buf) >= 50: buf = buf[-50:] buf.insert(0, '(Showing only the last 50 entries)\n') buf = '\n'.join(buf) return ( ('Genesis %s bug report\n' + '--------------------\n\n' + 'System: %s\n' + 'Detected platform: %s\n' + 'Detected distro: %s\n' + 'Python: %s\n\n' + 'Config path: %s\n\n' + '%s\n\n' 'Loaded plugins:\n%s\n\n' + 'Log:\n%s\n') % ( version(), shell('uname -a'), detect_platform(), detect_distro(), '.'.join([str(x) for x in platform.python_version_tuple()]), app.config.filename, err, pr, buf, ))
def make_report(app, err): """ Formats a bug report. """ from genesis.plugmgr import PluginLoader pr = '' for p in sorted(PluginLoader.list_plugins().keys()): pr += p + '\n' # Finalize the reported log app.log.blackbox.stop() return (('Genesis %s bug report\n' + '--------------------\n\n' + 'System: %s\n' + 'Detected platform: %s\n' + 'Detected distro: %s\n' + 'Python: %s\n\n' + 'Config path: %s\n\n' + '%s\n\n' 'Loaded plugins:\n%s\n\n' + 'Log:\n%s\n' ) % (version(), shell('uname -a'), detect_platform(), detect_distro(), '.'.join([str(x) for x in platform.python_version_tuple()]), app.config.filename, err, pr, app.log.blackbox.buffer, ))
def __new__(cls, *args, **kwargs): """ Returns a class instance, If it already instantiated, return it otherwise return new instance """ if issubclass(cls, PluginManager): # If we also a PluginManager, just create and return self = super(Plugin, cls).__new__(cls) self.plugin_manager = self return self # Normal case when we are standalone plugin self = None plugin_manager = args[0] if not cls.multi_instance: self = plugin_manager.instance_get(cls) if self is None: self = super(Plugin, cls).__new__(cls) self.plugin_manager = plugin_manager self.plugin_id = cls.__name__.lower() from genesis.plugmgr import PluginLoader pl, mod = PluginLoader.list_plugins(), cls.__module__.split('.')[0] self.plugin_info = pl[mod] if pl.has_key(mod) else None # Allow PluginManager implementation to update Plugin plugin_manager.plugin_activated(self) return self
def __new__(cls, *args, **kwargs): """ Returns a class instance, If it already instantiated, return it otherwise return new instance """ if issubclass(cls, PluginManager): # If we also a PluginManager, just create and return self = super(Plugin, cls).__new__(cls) self.plugin_manager = self return self # Normal case when we are standalone plugin self = None plugin_manager = args[0] if not cls.multi_instance: self = plugin_manager.instance_get(cls) if self is None: self = super(Plugin, cls).__new__(cls) self.plugin_manager = plugin_manager self.plugin_id = cls.__name__.lower() from genesis.plugmgr import PluginLoader pl, mod = PluginLoader.list_plugins(), cls.__module__.split('.')[0] self.pid = pl[mod].id if pl.has_key(mod) else cls.__module__.split('.')[2] self.plugin_info = pl[mod] if pl.has_key(mod) else None # Allow PluginManager implementation to update Plugin plugin_manager.plugin_activated(self) return self
def refresh_plugin_data(self): """ Rescans plugins for JS, CSS, LESS, XSLT widgets and XML templates. """ self.template_path = [] self.less_styles = [] self.woff_fonts = [] self.eot_fonts = [] self.svg_fonts = [] self.ttf_fonts = [] self.template_styles = [] self.template_scripts = [] self.layouts = {} includes = [] functions = {} for f in self.grab_plugins(IXSLTFunctionProvider): functions.update(f.get_funcs()) # Get path for static content and templates plugins = [] plugins.extend(PluginLoader.list_plugins().keys()) plugins.extend(genesis.plugins.plist) for c in plugins: path = os.path.join(PluginLoader.get_plugin_path(self, c), c) fp = os.path.join(path, "files") if os.path.exists(fp): self.template_styles.extend(["/dl/" + c + "/" + s for s in os.listdir(fp) if s.endswith(".css")]) self.less_styles.extend(["/dl/" + c + "/" + s for s in os.listdir(fp) if s.endswith(".less")]) self.woff_fonts.extend(["/dl/" + c + "/" + s for s in os.listdir(fp) if s.endswith(".woff")]) self.eot_fonts.extend(["/dl/" + c + "/" + s for s in os.listdir(fp) if s.endswith(".eot")]) self.svg_fonts.extend(["/dl/" + c + "/" + s for s in os.listdir(fp) if s.endswith(".svg")]) self.ttf_fonts.extend(["/dl/" + c + "/" + s for s in os.listdir(fp) if s.endswith(".ttf")]) self.template_scripts.extend(["/dl/" + c + "/" + s for s in os.listdir(fp) if s.endswith(".js")]) wp = os.path.join(path, "widgets") if os.path.exists(wp): includes.extend([os.path.join(wp, s) for s in os.listdir(wp) if s.endswith(".xslt")]) lp = os.path.join(path, "layout") if os.path.exists(lp): for s in os.listdir(lp): if s.endswith(".xml"): self.layouts["%s:%s" % (c, s)] = os.path.join(lp, s) tp = os.path.join(path, "templates") if os.path.exists(tp): self.template_path.append(tp) if xslt.xslt is None: xslt.prepare(includes, functions)
def scan_plugins(self): lst = PluginLoader.list_plugins() for c in lst: if hasattr(lst[c], 'services'): for s in self.servers: if lst[c].id == s.plugin_id: break else: for p in lst[c].services: try: if p['ports'] != []: self.add(lst[c].id, p['binary'], p['name'], lst[c].icon, p['ports']) except IndexError: pass
def scan_plugins(self): lst = PluginLoader.list_plugins() for c in lst: if hasattr(lst[c], 'services'): for s in self.servers: if lst[c].id == s.plugin_id: break else: for p in lst[c].services: try: if p['ports'] != []: self.add(lst[c].id, p['binary'], p['name'], lst[c].icon, p['ports']) except IndexError: pass
def make_report(app, err): """ Formats a bug report. """ from genesis.plugmgr import PluginLoader pr = '' k = PluginLoader.list_plugins() for p in sorted(k.keys()): pr += "%s %s\n" % (p, k[p].version) # Finalize the reported log app.log.blackbox.stop() buf = app.log.blackbox.buffer.split('\n') if len(buf) >= 50: buf = buf[-50:] buf.insert(0, '(Showing only the last 50 entries)\n') buf = '\n'.join(buf) return (('Genesis %s bug report\n' + '--------------------\n\n' + 'System: %s\n' + 'Detected platform: %s\n' + 'Detected distro: %s\n' + 'Python: %s\n\n' + 'Config path: %s\n\n' + '%s\n\n' 'Loaded plugins:\n%s\n\n' + 'Log:\n%s\n' ) % (version(), shell('uname -a'), detect_platform(), detect_distro(), '.'.join([str(x) for x in platform.python_version_tuple()]), app.config.filename, err, pr, buf, ))
def refresh_plugin_data(self): """ Rescans plugins for JS, CSS, LESS, XSLT widgets and XML templates. """ self.template_path = [] self.less_styles = [] self.template_styles = [] self.template_scripts = [] self.layouts = {} includes = [] functions = {} for f in self.grab_plugins(IXSLTFunctionProvider): functions.update(f.get_funcs()) # Get path for static content and templates plugins = [] plugins.extend(PluginLoader.list_plugins().keys()) plugins.extend(genesis.plugins.plist) for c in plugins: path = os.path.join(PluginLoader.get_plugin_path(self, c), c) fp = os.path.join(path, 'files') if os.path.exists(fp): self.template_styles.extend([ '/dl/'+c+'/'+s for s in os.listdir(fp) if s.endswith('.css') ]) self.less_styles.extend([ '/dl/'+c+'/'+s for s in os.listdir(fp) if s.endswith('.less') ]) self.template_scripts.extend([ '/dl/'+c+'/'+s for s in os.listdir(fp) if s.endswith('.js') ]) wp = os.path.join(path, 'widgets') if os.path.exists(wp): includes.extend([ os.path.join(wp, s) for s in os.listdir(wp) if s.endswith('.xslt') ]) lp = os.path.join(path, 'layout') if os.path.exists(lp): for s in os.listdir(lp): if s.endswith('.xml'): self.layouts['%s:%s'%(c,s)] = os.path.join(lp, s) tp = os.path.join(path, 'templates') if os.path.exists(tp): self.template_path.append(tp) if xslt.xslt is None: xslt.prepare( includes, functions )
def refresh_plugin_data(self): """ Rescans plugins for JS, CSS, LESS, XSLT widgets and XML templates. """ self.template_path = [] self.less_styles = [] self.woff_fonts = [] self.eot_fonts = [] self.svg_fonts = [] self.ttf_fonts = [] self.template_styles = [] self.template_scripts = [] self.layouts = {} includes = [] functions = {} for f in self.grab_plugins(IXSLTFunctionProvider): functions.update(f.get_funcs()) # Get path for static content and templates plugins = [] plugins.extend(PluginLoader.list_plugins().keys()) plugins.extend(genesis.plugins.plist) for c in plugins: path = os.path.join(PluginLoader.get_plugin_path(self, c), c) fp = os.path.join(path, 'files') if os.path.exists(fp): self.template_styles.extend([ '/dl/' + c + '/' + s for s in os.listdir(fp) if s.endswith('.css') ]) self.less_styles.extend([ '/dl/' + c + '/' + s for s in os.listdir(fp) if s.endswith('.less') ]) self.woff_fonts.extend([ '/dl/' + c + '/' + s for s in os.listdir(fp) if s.endswith('.woff') ]) self.eot_fonts.extend([ '/dl/' + c + '/' + s for s in os.listdir(fp) if s.endswith('.eot') ]) self.svg_fonts.extend([ '/dl/' + c + '/' + s for s in os.listdir(fp) if s.endswith('.svg') ]) self.ttf_fonts.extend([ '/dl/' + c + '/' + s for s in os.listdir(fp) if s.endswith('.ttf') ]) self.template_scripts.extend([ '/dl/' + c + '/' + s for s in os.listdir(fp) if s.endswith('.js') ]) wp = os.path.join(path, 'widgets') if os.path.exists(wp): includes.extend([ os.path.join(wp, s) for s in os.listdir(wp) if s.endswith('.xslt') ]) lp = os.path.join(path, 'layout') if os.path.exists(lp): for s in os.listdir(lp): if s.endswith('.xml'): self.layouts['%s:%s' % (c, s)] = os.path.join(lp, s) tp = os.path.join(path, 'templates') if os.path.exists(tp): self.template_path.append(tp) if xslt.xslt is None: xslt.prepare(includes, functions)