本文整理汇总了Python中pushbullet.Pushbullet类的典型用法代码示例。如果您正苦于以下问题:Python Pushbullet类的具体用法?Python Pushbullet怎么用?Python Pushbullet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pushbullet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkupsstatus
def checkupsstatus():
print '\ncheckupsstatus()'
global ups_status
global battery_charge
global battery_runtime
global output_voltage
try :
#initialize pushbullet
global ACCESS_TOKEN
# if 230V is present
if ups_status == "OL CHRG":
logmessage = " OK, ups is powered"
# if power outtage is detected
elif ups_status == "OB DISCHRG" :
logmessage = time.strftime("%Y-%m-%d %H:%M:%S") + "\n panne de courant !\n Batterie a "+ str(battery_charge) +"%, "+ str(battery_runtime) +" minutes restantes."
# send message through pushbullet to user
pb = Pushbullet(ACCESS_TOKEN)
push = pb.push_note("Domini - onduleur", logmessage)
else :
# status unknow
logmessage = time.strftime("%Y-%m-%d %H:%M:%S") + "\n etat inconnu : " + str(ups_status)+ ".\n Batterie a "+ str(battery_charge) +"%, "+ str(battery_runtime) +" minutes restantes."
# send message through pushbullet to user
pb = Pushbullet(ACCESS_TOKEN)
push = pb.push_note("Domini - onduleur", logmessage)
# print message and log it
print logmessage
syslog.syslog(logmessage)
except :
logmessage = " Error while reading or parsing UPS Variables"
print logmessage
syslog.syslog(logmessage)
示例2: main
def main():
apikey = settings.key
users = settings.users
if apikey == '':
print('No pushbullet apikey found in pushy.conf file, or bad formatting')
input('Press enter to exit\n>>')
return
if len(users) < 1:
print('No users found in settings.py. Please specifiy at least one (main) user.')
input('Press enter to exit \n>>')
return
pb = Pushbullet(apikey)
startup = pb.push_note("Pushy Listener Initiated", "auto start on reboot")
handler = PushHandler(pb, users)
s = Listener(account=pb,
on_push = handler.receive,
http_proxy_host = Http_Proxy_Host,
http_proxy_port = Http_Proxy_Port)
try:
s.run_forever()
except (Exception, KeyboardInterrupt) as exc:
close = pb.push_note('Pushy Listener Closed', '{}'.format(exc))
else:
s.close()
示例3: on_notification
def on_notification(change):
pb = Pushbullet(self.access_token)
for group in change.n_groups:
for n in group.notifications:
msg = u"Repo. : {0}\n".format(group.group_name)
msg += u"Title : {0}\nLink : {1}\nPerson : {2}\nText : {3}".format(n.title, n.link, n.person, n.text)
push = pb.push_note(u"Github Pushbullet - Notification", msg)
示例4: push_item
def push_item(items):
pb = Pushbullet(API_KEY)
for item in items:
if item["price"] == -1:
price_info = "No price: "
else:
price_info = str(item["price"]) + ":- | "
push = pb.push_link(price_info + item["title"], item["url"])
示例5: main
def main():
im = Image.open("taehui.jpg")
g_im = im.convert('L')
g_im.save('taehui_gray.jpg', 'JPEG')
pb = Pushbullet('o.cJzinoZ3SdlW7JxYeDm7tbIrueQAW5aK')
with open('taehui_gray.jpg', 'rb') as pic:
file_data = pb.upload_file(pic, 'taehui_gray.jpg')
print(**file_data)
示例6: _send_message
def _send_message(self, message, **kwargs):
try:
pb = Pushbullet(autosubliminal.PUSHBULLETAPI)
pb.push_note(title=self.notification_title, body=message)
return True
except Exception:
log.exception('%s notification failed', self.name)
return False
示例7: post
def post(self):
pb = Pushbullet(API_KEY)
push = pb.push_note(title, note)
s = Listener(account=pb,
on_push=on_push,
http_proxy_host=HTTP_PROXY_HOST,
http_proxy_port=HTTP_PROXY_PORT)
示例8: push_chart
def push_chart(self):
""" Pushes the chart to a Pushbullet account. """
pb = Pushbullet(config.PB_API_KEY)
with open('./today.jpg', 'rb') as pic:
file_data = pb.upload_file(pic, 'today.jpg')
pb.push_file(**file_data)
示例9: on_change
def on_change(title, link):
title = HTMLParser().unescape(title)
api_key = read_file('api_key')
if api_key:
pb = Pushbullet(api_key.strip())
pb.push_link(title, link)
else:
print('No api_key file available. Push not sent')
示例10: loop
def loop():
reduser = reddit_object.redditor("{redditor username}")
for post in reduser.submissions.new(limit=1):
if "ama" in post.title.lower() and post.id != last_ama_id:
push_bullet = Pushbullet(pushbullet_access_token)
my_phone = push_bullet.get_device("{device identifier}")
my_phone.push_note("AMA Posted","User {redditor username} is doing an AMA!")
exit()
threading.Timer(10.0,loop).start()
示例11: send_push
def send_push():
try:
title = "INTRUSION"
text = "movement detected"
from pushbullet import Pushbullet
API_KEY = 'o.nYHrQiyqBr2NTj59HaQFSSGsgoLDYQrv'
pb = Pushbullet(API_KEY)
push = pb.push_note(title,text)
except: pass
示例12: on_file_received
def on_file_received(self, file):
print "File received " + file
#super(MyHandler, self).on_file_sent(self, file)
pb = Pushbullet(api_key)
with open(file, "rb") as pic:
file_data = pb.upload_file(pic, file)
push = pb.push_file(**file_data)
示例13: send_pushbullet
def send_pushbullet(self):
pb = Pushbullet(self.pushbullet_token)
if self.file_path is not None:
with open(self.file_path, "rb") as f:
file_data = pb.upload_file(f, f.name.replace("-", ""))
response = pb.push_file(**file_data)
else:
pb.push_note("Motion detected!", "Motion detected, could not find preview image")
print "PiSN: Pushbullet notification succesfully pushed"
示例14: push
def push(msg):
api_key="kO3wYXQB6WQlQp7A5AN7WcPqdMOWy1Xx"
pb = Pushbullet(api_key)
# ip = subprocess.check_output("/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'", shell=True)
devlist=[x.nickname.encode('UTF-8') for x in pb.devices]
if 'Rpi' not in devlist:
pb.new_device('Rpi')
for dev in pb.devices:
push = dev.push_note('Rpi is up! ',msg)
示例15: new_transaction
def new_transaction():
r = json.loads(request.data)
if r['type'] == 'transaction.created':
amount = '\u00a3{0:.2f}'.format(float(r['data']['amount'])*-1)
description = r['data']['description']
message_title = '{} spent'.format(amount, description)
message_body = '@ {}'.format(amount, description)
pb = Pushbullet(os.environ.get('pushbullet_key'))
push = pb.push_note(message_title, message)
return message