当前位置: 首页>>代码示例>>Python>>正文


Python PushBullet.push_file方法代码示例

本文整理汇总了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 
开发者ID:JamestheLeet,项目名称:IPCamera-Controller,代码行数:12,代码来源:AlertSystems.py

示例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")
开发者ID:PhompAng,项目名称:To-do-Bullet,代码行数:14,代码来源:server.py

示例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)
开发者ID:srahmati,项目名称:SmartDoor,代码行数:40,代码来源:SmartDoor.py

示例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)

开发者ID:deepaksrivastav,项目名称:pyBabyMonitor,代码行数:16,代码来源:pyBabyMonitor.py

示例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)
开发者ID:Jpub,项目名称:RaspberryPiWithIOT,代码行数:11,代码来源:pushimage.py


注:本文中的pushbullet.PushBullet.push_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。