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