本文整理汇总了Python中pushbullet.PushBullet.pushAddress方法的典型用法代码示例。如果您正苦于以下问题:Python PushBullet.pushAddress方法的具体用法?Python PushBullet.pushAddress怎么用?Python PushBullet.pushAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pushbullet.PushBullet
的用法示例。
在下文中一共展示了PushBullet.pushAddress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pushAddress
# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import pushAddress [as 别名]
def pushAddress(args):
p = PushBullet(args.api_key)
address = p.pushAddress(args.device, args.name, " ".join(args.address))
if args.json:
print(json.dumps(address))
return
print("Address %s sent to %s" % (address["iden"], address["target_device_iden"]))
示例2: pushAddress
# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import pushAddress [as 别名]
def pushAddress(args):
p = PushBullet(args.api_key)
address = p.pushAddress(args.device, args.name, " ".join(args.address))
if args.json:
print(json.dumps(address))
return
if args.device and args.device[0] == '#':
print("Address broadcast to channel %s" % (args.device))
elif not args.device:
print("Address %s sent to all devices" % (address["iden"]))
else:
print("Address %s sent to %s" % (address["iden"], address["target_device_iden"]))
示例3: pushAddress
# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import pushAddress [as 别名]
def pushAddress(args):
p = PushBullet(args.api_key)
try:
address = p.pushAddress(args.device, args.name, " ".join(args.address))
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(address)
return
if "created" in address:
print("OK")
else:
print("ERROR %s" % (address))