Esempio n. 1
0
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)
Esempio n. 2
0
 def start(self):
     self.event = sched.enter(self.delay, 1, self.execute, ())
     try:
         sched.run()
     except:
         pass
Esempio n. 3
0
 def start(self):
     self.event = sched.enter(self.delay, 1, self.execute, ())
     try:
         sched.run()
     except:  # pylint:disable=bare-except
         pass
Esempio n. 4
0
 def start(self):
     self.event = sched.enter(self.delay, 1, self.execute, ())
     try:
         sched.run()
     except:
         pass
Esempio n. 5
0
 def refresh(label, widget, refreshrate):
     if len(clients) > 0:
         queue.put((label, widget()))
     sched.enter(refreshrate, 1, refresh, (label, widget, refreshrate))
Esempio n. 6
0
 def start(self):
     self.event = sched.enter(self.delay, 1, self.execute, ())
     try:
         sched.run()
     except:  #pylint:disable=bare-except
         pass
Esempio n. 7
0
 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))
Esempio n. 8
0
def main():

    sched.enter(1, 1, sqlping, (sched, ))
    sched.run()
Esempio n. 9
0
 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))