本文整理汇总了Python中pushbullet.PushBullet.push_file方法的典型用法代码示例。如果您正苦于以下问题:Python PushBullet.push_file方法的具体用法?Python PushBullet.push_file怎么用?Python PushBullet.push_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pushbullet.PushBullet
的用法示例。
在下文中一共展示了PushBullet.push_file方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_file [as 别名]
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
示例2: push
# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_file [as 别名]
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")
示例3: take_photo_and_push
# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_file [as 别名]
def take_photo_and_push(pushbullet_auth_key, pushbullet_device_names):
""" Takes a photo and sends to the cloud via PushBullet.
Implements pushbullet.py, see https://pypi.python.org/pypi/pushbullet.py
Implements picamera.py, see http://raspberrypi.org/picamera-pure-python-interface-for-camera-module
"""
file_name = datetime.datetime.now().strftime("%I:%M%p %m-%d-%Y") + '.jpg'
file_path = os.path.join('/home/pi', file_name)
with picamera.PiCamera() as camera:
camera.vflip = True
camera.hflip = True
camera.resolution = (1024, 768)
camera.capture(file_path)
pb = PushBullet(pushbullet_auth_key)
with open(file_path, 'rb') as pic:
message = 'SmartDoor ' + re.sub('.png', "", file_name)
success, file_data = pb.upload_file(pic, message, 'image/jpeg',)
upload_message = "{0} uploading picture {1} to url {2}".format(
'Success' if str(success) else 'Failure',
file_data.get('file_name'),
file_data.get('file_url'))
print(upload_message)
devices = pb.devices
if any([item in pushbullet_device_names for item in pushbullet_device_names]):
for deviceName in pushbullet_device_names:
device_list = [d for d in devices if d.nickname == deviceName and d.active]
device = device_list[0] if device_list else None
if device is not None:
success, push = device.push_file(**file_data)
print('Successfully pushed ' + push.get('iden') + ' to ' + device.nickname)
else:
success, push = pb.push_file(**file_data)
print('Successfully pushed ' + push.get('iden') + ' to all devices')
os.remove(file_path)
示例4: PushBullet
# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_file [as 别名]
#!/usr/python
from pushbullet import PushBullet
from subprocess import call
import time
pb = PushBullet('KEY_HERE')
while True:
call(["streamer","-f", "jpeg", "-o","image.jpeg"])
with open("image.jpeg", "rb") as pic:
success, file_data = pb.upload_file(pic, "picture.jpg")
success, push = pb.push_file(**file_data)
time.sleep(600)
示例5: PushBullet
# 需要导入模块: from pushbullet import PushBullet [as 别名]
# 或者: from pushbullet.PushBullet import push_file [as 别名]
from pushbullet import PushBullet
api_key = "q3U8S546S0D8tHJb8PrCzHaKABoHbnZy"
pb = PushBullet(api_key)
with open("gem1.png", "rb") as pic:
file_data = pb.upload_file(pic, "gem1.png")
push = pb.push_file(**file_data)