コード例 #1
0
ファイル: sched.py プロジェクト: 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)
コード例 #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)
コード例 #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
コード例 #4
0
ファイル: __init__.py プロジェクト: meskio/emma
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