Exemplo n.º 1
0
def pushbullet_magic():
    p = PushBullet(config["access_token"])
    devices = p.getDevices()
    iden = ""
    for dev in devices:
        if ("nickname" in dev.keys() and
                dev["nickname"] == config["device_nickname"]):
            iden = dev["iden"]
            break
    return [p, iden]
Exemplo n.º 2
0
def get_iden(token, device):
    try:
        p = PushBullet(token)
        devices = p.getDevices()
        for dev in devices:
            if ("nickname" in dev.keys() and dev["nickname"] == device):
                iden = dev["iden"]
                break
        return iden
    except requests.ConnectionError:
        return False
Exemplo n.º 3
0
def get_iden(token, device):
    try:
        p = PushBullet(token)
        devices = p.getDevices()
        for dev in devices:
            if ("nickname" in dev.keys() and
                    dev["nickname"] == device):
                iden = dev["iden"]
                break
        return iden
    except requests.ConnectionError:
        return False
Exemplo n.º 4
0
def validate(token):
    try:
        p = PushBullet(token)
        devices = p.getDevices()
        nick = [False]
        for dev in devices:
            if "nickname" in dev.keys():
                nick.append(dev["nickname"])
        return nick
    except requests.HTTPError:
        return [True]
    except requests.ConnectionError:
        return ["conn_err"]
Exemplo n.º 5
0
def validate(token):
    try:
        p = PushBullet(token)
        devices = p.getDevices()
        nick = [False]
        for dev in devices:
            if "nickname" in dev.keys():
                nick.append(dev["nickname"])
        return nick
    except requests.HTTPError:
        return [True]
    except requests.ConnectionError:
        return ["conn_err"]
Exemplo n.º 6
0
    valid = ["city", "movie_name", "language", "month", "day",
             "access_token", "device_iden", "device_nickname"]
    # filter empty config values and end program if any value is empty
    filter_config = dict((k, v) for k, v in config.items() if v and k in valid)
    if len(filter_config) != len(valid):
        return False
    else:
        return True


def main():
    if check_config():
        url = get_movie_url()
        result = get_show_times(url)
        if result:
            pushed = push_it(result)
            if pushed[0] is None:
                print("No matching devices found!")
            elif pushed[0]:
                print("{0}\n{1}".format(pushed[1], pushed[2]))
            else:
                print("Connection error!")
    else:
        print("Check config.ini for incorrect/missing values!")


if __name__ == "__main__":
    config = configobj.ConfigObj("config.ini")
    p = PushBullet(config["access_token"])
    main()