def pushList(args): p = PushBullet(args.api_key) lst = p.pushList(args.device, args.title, args.list) if args.json: print(json.dumps(lst)) return print("List %s sent to %s" % (lst["iden"], lst["target_device_iden"]))
def pushList(args): p = PushBullet(args.api_key) lst = p.pushList(args.device, args.title, args.list) if args.json: print(json.dumps(lst)) return if args.device and args.device[0] == '#': print("List broadcast to channel %s" % (args.device)) elif not args.device: print("List %s sent to all devices" % (lst["iden"])) else: print("List %s sent to %s" % (lst["iden"], lst["target_device_iden"]))
def pushList(args): p = PushBullet(args.api_key) try: lst = p.pushList(args.device, args.title, args.list) except HTTPError: _, e, _ = sys.exc_info() print("The server couldn\'t fulfill the request.") print("Error code: %s" % (e.code)) except URLError: _, e, _ = sys.exc_info() print("We failed to reach a server.") print("Reason: %s" % (e.reason)) else: if args.json: print(lst) return if "created" in lst: print("OK") else: print("ERROR %s" % (lst))