def loadmodules(modules): def refresh(label, widget, refreshrate): if len(clients) > 0: queue.put((label, widget())) sched.enter(refreshrate, 1, refresh, (label, widget, refreshrate)) assets = {'js': set(), 'css': set()} components = {} for module in modules: path = 'modules/{}'.format(module['name']) if os.path.isdir(path): # Load CSS and JS files for entry in os.listdir(path): (name, ext) = os.path.splitext(entry) if ext == '.css': assets['css'].add('{}/{}'.format(path, entry)) elif ext == '.js': assets['js'].add('{}/{}'.format(path, entry)) # Load widgets and schedule automatic refresh mod = importlib.import_module('modules.{0}.{0}'.format(module['name'])) for name, obj in inspect.getmembers(mod): if inspect.isclass(obj) and name != 'Module': obj = obj(module['config']) if 'config' in module else obj() widget = obj.widget() components[module['label']] = {'object': obj, 'widget': widget} if obj.refreshrate is not None: sched.enter(obj.refreshrate, 1, refresh, (module['label'], widget, obj.refreshrate)) return (assets, components)
def start(self): self.event = sched.enter(self.delay, 1, self.execute, ()) try: sched.run() except: pass
def start(self): self.event = sched.enter(self.delay, 1, self.execute, ()) try: sched.run() except: # pylint:disable=bare-except pass
def refresh(label, widget, refreshrate): if len(clients) > 0: queue.put((label, widget())) sched.enter(refreshrate, 1, refresh, (label, widget, refreshrate))
def start(self): self.event = sched.enter(self.delay, 1, self.execute, ()) try: sched.run() except: #pylint:disable=bare-except pass
def start(self): self.event = sched.enter(self.delay, 1, self.execute, ()) try: sched.run() except Exception as e: log.warning("[Timer] Scheduler error: %s", str(e))
def main(): sched.enter(1, 1, sqlping, (sched, )) sched.run()