本文整理汇总了Python中pushbullet.PushBullet类的典型用法代码示例。如果您正苦于以下问题:Python PushBullet类的具体用法?Python PushBullet怎么用?Python PushBullet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PushBullet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: notifyPushbullet
def notifyPushbullet(downlist):
"""
"""
#prepare the interface
pb = PushBullet(config.get("pushbullet_api_key"))
devices = []
#identify desired targets
for device in pb.devices:
devicename = device.name
deviceno = device.device_id
target = config.get("pushbullet_target_dev")
if target is not "":
if target == devicename:
devices.append(deviceno)
else:
devices.append(deviceno)
#prepare message
message = "The host(s): \n"
for dom in downlist:
message += " "+dom+" \n"
message += "seems to be down."
#actually push the messages
for deviceno in devices:
device = pb.get(deviceno)
push = device.push_note("server monitor", message)
if (push is None) or (push.status_code is not 200):
return False
return True
开发者ID:dalcacer,项目名称:pyhttpmon,代码行数:32,代码来源:pyhttpmon.py
示例2: plugin
def plugin(srv, item):
''' expects (apikey, device_id) in adddrs '''
srv.logging.debug("*** MODULE=%s: service=%s, target=%s", __file__, item.service, item.target)
if not HAVE_PUSHBULLET:
srv.logging.warn("pushbullet is not installed")
return False
try:
apikey, device_id = item.addrs
except:
srv.logging.warn("pushbullet target is incorrectly configured")
return False
text = item.message
title = item.get('title', srv.SCRIPTNAME)
try:
srv.logging.debug("Sending pushbullet notification to %s..." % (item.target))
pb = PushBullet(apikey)
pb.pushNote(device_id, title, text)
srv.logging.debug("Successfully sent pushbullet notification")
except Exception, e:
srv.logging.warning("Cannot notify pushbullet: %s" % (str(e)))
return False
开发者ID:ChristianKniep,项目名称:mqttwarn,代码行数:25,代码来源:pushbullet.py
示例3: send_notification
def send_notification(api_key, page_title, site_url):
print "Sending PushBullet notification"
pb_client = PushBullet(api_key)
pb_client.push_link("Update on {title}!".format(title=page_title), site_url)
开发者ID:MarcDufresne,项目名称:pushbullet-crawler,代码行数:7,代码来源:scrapper.py
示例4: pushAddress
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"]))
开发者ID:Mondego,项目名称:pyreco,代码行数:7,代码来源:allPythonContent.py
示例5: pushNote
def pushNote(args):
p = PushBullet(args.api_key)
note = p.pushNote(args.device, args.title, " ".join(args.body))
if args.json:
print(json.dumps(note))
return
print("Note %s sent to %s" % (note["iden"], note["target_device_iden"]))
开发者ID:Mondego,项目名称:pyreco,代码行数:7,代码来源:allPythonContent.py
示例6: pushLink
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"]))
开发者ID:Mondego,项目名称:pyreco,代码行数:7,代码来源:allPythonContent.py
示例7: pushList
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"]))
开发者ID:Mondego,项目名称:pyreco,代码行数:7,代码来源:allPythonContent.py
示例8: pushFile
def pushFile(args):
p = PushBullet(args.api_key)
file = p.pushFile(args.device, open(args.file, 'rb'))
if args.json:
print(json.dumps(file))
return
print("File %s sent to %s" % (file["iden"], file["target_device_iden"]))
开发者ID:Mondego,项目名称:pyreco,代码行数:7,代码来源:allPythonContent.py
示例9: __init__
class PBEventHandler:
def __init__(self):
self.KEY = KEY
self.HIST_FILE = HIST_FILE
self.pb = PushBullet(KEY)
self.maxmod = float(0)
self.iden = None
self._sync_maxmod()
self._sync_maxmod(self._get_modified())
devices = self.pb.getDevices()
for device in devices:
if device['nickname'] == DEVICE:
self.iden = device['iden']
break
def _get_modified(self):
return self.pb.getPushHistory(self.maxmod)
def _sync_maxmod(self, pushes = []):
for push in pushes:
if float(push['modified']) > self.maxmod:
self.maxmod = float(push['modified'])
n = float(self.maxmod)
try:
fn = float(open(self.HIST_FILE).read()) + 0.01
except:
fn = 0
fn = max(float(n), float(fn))
open(self.HIST_FILE, "w").write(str(fn))
self.maxmod = float(fn)
def _event(self, data, callback):
if data['type'] == 'tickle' and data['subtype'] == 'push':
pushes = self.pb.getPushHistory(self.maxmod)
for push in pushes:
if push['modified'] > self.maxmod:
self.maxmod = push['modified']
self._sync_maxmod()
if self.iden != None and\
push['target_device_iden'] != self.iden: continue
try:
callback(push)
except:
pass
def run(self, callback):
def __event(data):
print "event: " + str(data)
self._event(data, callback)
self.pb.realtime(__event)
开发者ID:smrt28,项目名称:pyPushBullet,代码行数:59,代码来源:pbevents.py
示例10: addDevice
def addDevice(args):
p = PushBullet(args.api_key)
devices = p.addDevice(args.nickname)
if args.json:
print(json.dumps(devices))
return
print("Device %s was assigned ID %s" % (devices["nickname"],
devices["iden"]))
开发者ID:kakai248,项目名称:pyPushBullet,代码行数:8,代码来源:pushbullet_cmd.py
示例11: getDevices
def getDevices(args):
p = PushBullet(args.api_key)
devices = p.getDevices()
if args.json:
print(json.dumps(devices))
return
for device in devices:
print("%s %s %s" % (device["iden"],
device["manufacturer"],
device["model"]))
开发者ID:Mondego,项目名称:pyreco,代码行数:10,代码来源:allPythonContent.py
示例12: pushNote
def pushNote(args):
p = PushBullet(args.api_key)
note = p.pushNote(args.device, args.title, " ".join(args.body))
if args.json:
print(note)
return
if "created" in note:
print("OK")
else:
print("ERROR %s" % (note))
开发者ID:wimac,项目名称:home,代码行数:10,代码来源:pushbullet_cmd.py
示例13: __init__
class PushBulletAlert:
def __init__(self, api_key, imagedir):
self.pb = PushBullet(api_key)
self.imagedir = imagedir
def sendAlert(self, image):
imagedata = open(os.path.join(self.imagedir, image), 'rb')
success, file_data = self.pb.upload_file(imagedata, 'Motion detected: ' + image)
success, push = self.pb.push_file(**file_data)
return success
开发者ID:JamestheLeet,项目名称:IPCamera-Controller,代码行数:10,代码来源:AlertSystems.py
示例14: send_push
def send_push(title, body):
pushbullet = PushBullet(api_key)
if not devices:
pushbullet.push_note(title=title, body=body)
else:
# load devices
d = pushbullet.devices
for i in devices:
d[i].push_note(title=title, body=body)
开发者ID:Saturn,项目名称:live-football-ontv,代码行数:10,代码来源:run.py
示例15: PushBulletNotify
class PushBulletNotify(object):
def __init__(self, api_key):
self.api_key = api_key
self.pb = PushBullet(api_key)
self.pb.reload_devices() # TODO is this needed?
def send(self, title, text):
for device in self.pb.devices:
device.push_note(title, text)
开发者ID:nyctef,项目名称:eveutils,代码行数:10,代码来源:pushbulletnotify.py
示例16: PB_Alarm
class PB_Alarm(Alarm):
def __init__(self, api_key):
self.client = PushBullet(api_key)
log.info("PB_Alarm intialized.")
push = self.client.push_note("PokeAlarm activated!", "We will alert you about pokemon.")
def pokemon_alert(self, pokemon):
notification_text = "A wild " + pokemon['name'].title() + " has appeared!"
google_maps_link = gmaps_link(pokemon["lat"], pokemon["lng"])
time_text = pkmn_time_text(pokemon['disappear_time'])
push = self.client.push_link(notification_text, google_maps_link, body=time_text)
开发者ID:ykurtbas,项目名称:PokemonGo-Map,代码行数:11,代码来源:pb_alarm.py
示例17: pushbullet_post
def pushbullet_post(self, issue):
""" Posts to Pushbullet API.
For future reference, the push_note() function returns two
values. One bool that specificies whether the push was a success
or not, and a dict with additional info.
"""
pb = PushBullet('YOUR-API-KEY')
worked, push = pb.push_note(u"Förseningar", issue)
if not worked:
print(push)
开发者ID:johanberglind,项目名称:SLNotify,代码行数:11,代码来源:SLNotify.py
示例18: pushNote
def pushNote(args):
p = PushBullet(args.api_key)
note = p.pushNote(args.device, args.title, " ".join(args.body))
if args.json:
print(json.dumps(note))
return
if args.device and args.device[0] == '#':
print("Note broadcast to channel %s" % (args.device))
elif not args.device:
print("Note %s sent to all devices" % (note["iden"]))
else:
print("Note %s sent to %s" % (note["iden"], note["target_device_iden"]))
开发者ID:kakai248,项目名称:pyPushBullet,代码行数:12,代码来源:pushbullet_cmd.py
示例19: push
def push(self):
""" Push a task """
p = PushBullet(self.api)
if self.type == 'text':
success, push = p.push_note(self.title, self.message)
elif self.type == 'list':
self.message = self.message.split(',')
success, push = p.push_list(self.title, self.message)
elif self.type == 'link':
success, push = p.push_link(self.title, self.message)
else:
success, push = p.push_file(file_url=self.message, file_name="cat.jpg", file_type="image/jpeg")
开发者ID:PhompAng,项目名称:To-do-Bullet,代码行数:12,代码来源:server.py
示例20: pushLink
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"]))
开发者ID:kakai248,项目名称:pyPushBullet,代码行数:12,代码来源:pushbullet_cmd.py
注:本文中的pushbullet.PushBullet类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论