Example #1
0
        return
    data = " ".join(data)
    globals()[action](data)


def reminder_quit():
    """
    This function has to be called when shutting down. It terminates all waiting threads.
    """
    try:
        for index, el in timerList.iteritems():
            el.cancel()
    except:
        for index, el in timerList.items():
            el.cancel()


timerList = {}
reminderList = read_file("reminderlist.txt", {'items': []})
reminderList['items'] = sort(reminderList['items'])
reminderList['items'] = [i for i in reminderList['items'] if not i['hidden']]
notify2.init("Jarvis")
for e in reminderList['items']:
    e['time'] = str2date(e['time'])
    waitTime = e['time'] - dt.now()
    n = notify2.Notification(e['name'])
    n.set_urgency(0)
    timerList[e['uuid']] = Timer(waitTime.total_seconds(), showAlarm,
                                 [n, e['name']])
    timerList[e['uuid']].start()
Example #2
0
                                                 trigger,
                                                 distance_penalty=0.5,
                                                 additional_target_penalty=0,
                                                 word_match_penalty=0.5)
            if foundMatch and len(indexList) > len(indices):
                # A match for this action was already found.
                # But this trigger matches more words.
                indices = indexList
            if newScore < score:
                if not foundMatch:
                    indices = indexList
                    minArgs = actions[key]['minArgs']
                    foundMatch = True
                score = newScore
                action = key
    if not action:
        return
    data = data.split()
    for i in sorted(indices, reverse=True):
        del data[i]
    if len(data) < minArgs:
        warning(
            "Not enough arguments for specified command {0}".format(action))
        return
    data = " ".join(data)
    globals()[action](data)


todoList = read_file("todolist.txt", {'items': []})
todoList['items'] = fixTypes(sort(todoList['items']))