Beispiel #1
0
def main():
    expire_todos()

    parser = create_parser()

    args = parser.parse_args()  # Dictionary with key names as options

    todos = get_all_todos()

    args = vars(args)
    if all(args[key] == None for key in args.keys()):
        display_todos()
    else:
        if args["new"] != None:
            if args["due"] is not None:
                add_todo(args["new"], args["due"][0])
            else:
                add_todo(args["new"], None)
        if args["done"] != None:
            set_todo_status(todos, int(args["done"][0]), True)
        if args["undone"] != None:
            set_todo_status(todos, int(args["undone"][0]), False)
        if args["remove"] != None:
            delete_by_index(todos, int(args["remove"][0]))
        if args["edit"] != None:
            update_by_index(todos, int(args["edit"][0]))
        if args["clear"] != None:
            clear()
        if args["expire"] != None:
            expire_overdue_todos(todos)
        if args["quotes"] != None:
            quotes(int(args["quotes"][0]))
        display_todos()
def startup():
    print("initializing")
    clear()
    s = scraper()
    s.populate()
    s.navigate(setup=True)
    print("database created")
    return
Beispiel #3
0
    print("Unable to read config file")
    print(e)
    exit(1)

alerts_triggered = 0

while True:
    try:
        gchotels_config = modules.create_config_object(config)
        date_range = modules.all_dates_list(gchotels_config.check_in,
                                            gchotels_config.check_out)
        hotel_room_json = modules.get_hotel_room_objects(gchotels_config)
        hotel_room_objects = modules.hotel_room_parser(hotel_room_json,
                                                       gchotels_config)
        hotel_room_objects = modules.filter_hotel_room_objects(
            hotel_room_objects, gchotels_config)
        if (gchotels_config.alerts_email or gchotels_config.alerts_sms or gchotels_config.alerts_twitter) \
                and hotel_room_objects:
            modules.send_alerts(hotel_room_objects, gchotels_config)
            alerts_triggered = 1
        modules.clear()
        print(modules.table_creation(hotel_room_objects))
        if alerts_triggered == 1:
            time.sleep(60)
            alerts_triggered = 0
        else:
            time.sleep(gchotels_config.check_frequency)
    except Exception as e:
        print(e)
        exit(1)