Esempio n. 1
0
File: sched.py Progetto: meskio/emma
def _delay(event, data, seconds, date, doc_id=None):
    db = DB()
    core = db.core()
    if not doc_id:
        doc = {'element': 'sched',
            'type': 'at',
            'event': dumps(event.elements()),
            'data': dumps(data),
            'date': date}
        doc_id = core.insert(doc)

    if seconds > 0:
        sleep(float(seconds))
    trigger(event, data)
    core.remove(doc_id)
Esempio n. 2
0
def _delay(event, data, seconds, date, doc_id=None):
    db = DB()
    core = db.core()
    if not doc_id:
        doc = {
            'element': 'sched',
            'type': 'at',
            'event': dumps(event.elements()),
            'data': dumps(data),
            'date': date
        }
        doc_id = core.insert(doc)

    if seconds > 0:
        sleep(float(seconds))
    trigger(event, data)
    core.remove(doc_id)
Esempio n. 3
0
def main(conf_paths=confPaths):
    """
    Main function of the program

    It loads all the interfaces and modules described on the config files.
    """
    localedir = os.path.join(os.path.dirname(__file__), 'locale')
    conf = ConfigParser.RawConfigParser()
    conf.read(conf_paths)
    _init_log(conf)
    _init_i18n(conf, localedir)
    db = DB()
    db.connect(conf.get("core", "db_host"), int(conf.get("core", "db_port")),
               conf.get("core", "db_name"))
    core = db.core()
    _load_complements(conf)
    _restore_sched(core)

    while 1:
        sleep(1000)  # I didn't find any better wait method
Esempio n. 4
0
def main(conf_paths=confPaths):
    """
    Main function of the program

    It loads all the interfaces and modules described on the config files.
    """
    localedir = os.path.join(os.path.dirname(__file__), 'locale')
    conf = ConfigParser.RawConfigParser()
    conf.read(conf_paths)
    _init_log(conf)
    _init_i18n(conf, localedir)
    db = DB()
    db.connect(conf.get("core", "db_host"),
               int(conf.get("core", "db_port")),
               conf.get("core", "db_name"))
    core = db.core()
    _load_complements(conf)
    _restore_sched(core)

    while 1:
        sleep(1000)    # I didn't find any better wait method