Esempio n. 1
0
def dragon_greet():
    tts_kill()
    print("_______________________________________________________________\n")
    time = datetime.datetime.now().time()

    global user_full_name
    global user_prefix

    user_full_name = os.popen(
        "getent passwd $LOGNAME | cut -d: -f5 | cut -d, -f1").read()
    user_full_name = user_full_name[:-1]
    user_prefix = GENDER_PREFIX[Classifiers.gender(
        user_full_name.split(' ', 1)[0])]

    if time < datetime.time(12):
        userin = Data(["echo"], "To activate say 'Dragonfire!' or 'Wake Up!'")
        userin.say("Good morning " + user_prefix)
        userin.interact(0)
    elif datetime.time(12) < time and time < datetime.time(18):
        userin = Data(["echo"], "To activate say 'Dragonfire!' or 'Wake Up!'")
        userin.say("Good afternoon " + user_prefix)
        userin.interact(0)
    else:
        userin = Data(["echo"], "To activate say 'Dragonfire!' or 'Wake Up!'")
        userin.say("Good evening " + user_prefix)
        userin.interact(0)
Esempio n. 2
0
def dragon_greet():
    tts_kill()
    print("_______________________________________________________________\n")
    time = datetime.datetime.now().time()

    global user_full_name
    global user_prefix
    global config_file

    command = "getent passwd $LOGNAME | cut -d: -f5 | cut -d, -f1"
    user_full_name = os.popen(command).read()
    user_full_name = user_full_name[:-1].decode("utf8")
    home = expanduser("~")
    config_file = TinyDB(home + '/.dragonfire_config.json')
    callme_config = config_file.search(Query().datatype == 'callme')
    if callme_config:
        user_prefix = callme_config[0]['title'].encode("utf8")
    else:
        gender_config = config_file.search(Query().datatype == 'gender')
        if gender_config:
            user_prefix = GENDER_PREFIX[gender_config[0]['gender']]
        else:
            gender = Classifiers.gender(user_full_name.split(' ', 1)[0])
            config_file.insert({'datatype': 'gender', 'gender': gender})
            user_prefix = GENDER_PREFIX[gender]

    if time < datetime.time(12):
        time_of_day = "morning"
    elif datetime.time(12) < time < datetime.time(18):
        time_of_day = "afternoon"
    else:
        time_of_day = "evening"
    userin.define_and_execute(["echo"],
                              "To activate say 'Dragonfire!' or 'Wake Up!'")
    userin.say(" ".join(["Good", time_of_day, user_prefix]))