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


Python Pushbullet.upload_file方法代码示例

本文整理汇总了Python中pushbullet.Pushbullet.upload_file方法的典型用法代码示例。如果您正苦于以下问题:Python Pushbullet.upload_file方法的具体用法?Python Pushbullet.upload_file怎么用?Python Pushbullet.upload_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pushbullet.Pushbullet的用法示例。


在下文中一共展示了Pushbullet.upload_file方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import upload_file [as 别名]
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)
开发者ID:Dorry,项目名称:PyCCTV_NVR,代码行数:10,代码来源:image_test.py

示例2: on_file_received

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import upload_file [as 别名]
    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)
开发者ID:texnofobix,项目名称:Ftp2PushBullet,代码行数:11,代码来源:ftp2pushbullet.py

示例3: send_pushbullet

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import upload_file [as 别名]
 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"
开发者ID:kircon,项目名称:PiSN,代码行数:11,代码来源:notification_pushbullet.py

示例4: push_chart

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import upload_file [as 别名]
    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)
开发者ID:bcallaars,项目名称:plot-push-currency,代码行数:11,代码来源:start.py

示例5: push_file

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import upload_file [as 别名]
def push_file(filename):
	if is_device_connected(DEVICE_MAC):
		print "Device is connected, not sending"
		return
	print "Sending", filename

	pushbullet = Pushbullet(PUSHBULLET_API_KEY)
	my_device = pushbullet.get_device(PUSHBULLET_DEVICE_NAME)
	file_data = pushbullet.upload_file(open(filename, "rb"), filename)
	pushbullet.push_file(device = my_device, **file_data)
	print "Sent!"
开发者ID:icode-co-il,项目名称:home-security,代码行数:13,代码来源:home_security.py

示例6: SnapshotPipeline

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import upload_file [as 别名]
class SnapshotPipeline(Pipeline):
    def __init__(self):
        super(SnapshotPipeline, self).__init__('snap_pipe')
        
        self.file_source = ""
        self.pb = Pushbullet('o.cJzinoZ3SdlW7JxYeDm7tbIrueQAW5aK')
        
        self.create_snapshot()
        
        bus = self.pipe.get_bus()
        bus.add_signal_watch()
        bus.connect('message', self.on_message_cb, None)
        
    def create_snapshot(self):
        self.appsrc = Gst.ElementFactory.make('appsrc', 'snapsrc')
        self.pipe.add(self.appsrc)
        
        jpegenc = Gst.ElementFactory.make('jpegenc', 'jpegenc')
        self.pipe.add(jpegenc)
        
        self.filesink = Gst.ElementFactory.make('filesink', 'jpegfilesink')
        self.pipe.add(self.filesink)
        
        self.appsrc.link(jpegenc)
        jpegenc.link(self.filesink)
        
    def send_snapshot(self):
        dtime = Gst.DateTime.new_now_local_time()
        g_datetime = dtime.to_g_date_time()
        timestamp = g_datetime.format("%F_%H%M%S")
        timestamp = timestamp.replace("-", "")
        filename = "sshot_" + timestamp + ".jpg"
        self.file_source = filename
        print("Filename : %s" % filename)
        
        self.filesink.set_property('location', filename)
        self.filesink.set_property('async', False)
        
        self.pipe.set_state(Gst.State.PLAYING)
        
        
    def on_message_cb(self, bus, msg, data):
        t = msg.type
        if t == Gst.MessageType.ERROR:
            name = msg.src.get_path_string()
            err, debug = msg.parse_error()
            print("Snapshot pipeline -> Error received : from element %s : %s ." % (name, err.message))
            if debug is not None:
                print("Additional debug info:\n%s" % debug)
              
            self.pipe.set_state(Gst.State.NULL)
            self.file_source = ""
            
        elif t == Gst.MessageType.WARNING:
            name = msg.src.get_path_string()
            err, debug = msg.parse_warning()
            print("Snapshot pipeline -> Warning received : from element %s : %s ." % (name, err.message))
            if debug is not None:
                print("Additional debug info:\n%s" % debug)
            
        elif t == Gst.MessageType.EOS:
            print("Snapshot End-Of-Stream received")
            print(datetime.now())
            print("")
            self.pipe.set_state(Gst.State.NULL)
            
            if self.file_source != "":
                with open(self.file_source, 'rb') as pic:
                    file_data = self.pb.upload_file(pic, self.file_source)
                for key in file_data.keys():
                    print("%s in File data of value : %s" % (key , file_data[key]))
                push = self.pb.push_file(title="Motion detected", **file_data)
                print(push)
                self.file_source = ""
开发者ID:Dorry,项目名称:PyCCTV_NVR,代码行数:76,代码来源:pb_motion_test.py

示例7: kill_motion

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import upload_file [as 别名]

def kill_motion():
    """Ensure the motion process is not active (blue webcam light off)."""
    if process_running('motion'):
        print('Stopping motion')
        return subprocess.check_output('sudo killall motion'.split()).decode('utf-8')


while (True):
    if (not is_erics_iphone_in_home_network()):
        ensure_motion_is_running()
        for jpg in glob.glob(os.path.join(motion_dir, '*.jpg')):
            # TODO: log instead
            with open(jpg, 'rb') as pic:
                # TODO: only push if cell phone not in house wifi
                file_data = pb.upload_file(pic, name(pic))
                push = pb.push_file(**file_data)
                # TODO: try-catch with logging
                os.remove(jpg)
                # Clean up motion_dir: discard swfs for room
        	for swf in glob.glob(os.path.join(motion_dir, '*.swf')):
                    os.remove(swf)
    else:
        kill_motion()
        for file in glob.glob(os.path.join(motion_dir, '*')):
            os.remove(file)
        # TODO: log instead
        print('Eric is home -- sleeping')
    time.sleep(30)
开发者ID:EricCrosson,项目名称:momo,代码行数:31,代码来源:notify.py

示例8: __init__

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import upload_file [as 别名]
class RPiSurveillanceCamera:

    # Init class
    def __init__(self, configfile='config.json'):

        # Init config (load from JSON file)
        self.config = json.load(open(configfile))

        # Init camera
        self.camera = picamera.PiCamera()
        self.setupCamera()

        # Init GPIO pis
        self.initGPIO()

        # Init more stuff
        self.pushbullet = Pushbullet(self.config["pushbullet"]["accessToken"])
        self.outputDir = self.setOutputDirectory()

    # Setup camera
    def setupCamera(self):

        # Set resolution and framerate
        resolution = self.config["camera"]["resolution"]
        self.camera.resolution = (resolution["width"], resolution["height"])
        self.camera.framerate = self.config["camera"]["framerate"]

        # Set tags (Artist & Copyright) - in case of the images/videos getting online
        self.camera.exif_tags['IFD0.Artist'] = "{}".format(self.config["user"]["name"])
        self.camera.exif_tags['IFD0.Copyright'] = "© Copyright {} {}".format(
            time.strftime("%Y", time.localtime()),
            self.config["user"]["name"])

    # Init GPIO pins
    def initGPIO(self):

        # Set pin mode
        GPIO.setmode(GPIO.BCM)

        # Define GPIO pins
        ledSwitch = self.config["gpio"]["ledSwitch"]
        ledStatus = self.config["gpio"]["ledStatus"]
        sensorPin = self.config["gpio"]["sensor"]
        switchPin = self.config["gpio"]["switch"]

        # Set GPIO IN/OUT
        GPIO.setup(ledSwitch, GPIO.OUT)
        GPIO.setup(ledStatus, GPIO.OUT)
        GPIO.setup(sensorPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.setup(switchPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    # Set output directory path
    def setOutputDirectory(self):

        # Set output directory path from config
        outputDir = self.config["camera"]["outputDirectory"]

        # Create dir if necessary
        if not os.path.exists(outputDir):
            os.makedirs(outputDir)
            print("Created image folder: {}".format(outputDir))

        # Return directory path
        return outputDir

    # Taking a picture
    def makePicture(self):

        # Start camera preview
        self.camera.start_preview()

        # Set name for name (unique by time)
        fileName = 'picamera-shot-{}.jpg'.format(time.strftime("%y%m%d%H%M%S"))

        try:
            # Capture foto
            self.camera.capture(self.outputDir + fileName)

            # Log
            print("Picture: {}".format(self.outputDir + fileName))

        finally:
            # Close camera and return image path
            self.camera.close()
            return self.outputDir + fileName

    # Push image via Pushbullet
    def pushImage(self, image):

        # Open image
        with open(image, "rb") as pic:

            # Upload file to Pushbullet server
            file_data = self.pushbullet.upload_file(pic, "sample_iPod.m4v")

        # Push file
        self.pushbullet.push_file(**file_data)
开发者ID:christianewald,项目名称:RPiSecureSurveillanceCamera,代码行数:99,代码来源:camera.py

示例9: print

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import upload_file [as 别名]
	settings = json.load(f)
if settings['api_key'] == 'put_key_here':
	print('You should check the README on how to add your API key')
	exit(0)

try:
	pb = Pushbullet(settings['api_key'])
except:
	print ("Your API key is invalid")
	exit(1)

if settings['command_started_title'].isspace():
	if len(sys.argv) == 2:
		pb.push_note(settings['command_started_title'], 'Running command ' + sys.argv[1] + ' with no arguments')
	else:
		pb.push_note(settings['command_started_title'], 'Running command ' + sys.argv[1] + ' with arguments ' + str(sys.argv[2:]))

task_output = open('out.txt', 'w')
retcode = call(sys.argv[1:], stdout = task_output)
task_output.close()

with open('out.txt', 'rb') as f:
	filename = 'out_'+datetime.datetime.fromtimestamp(time.time()).strftime('%Y_%m_%d_%H%M%S')+'.txt'
	task_output_data = pb.upload_file(f, filename)
os.remove('out.txt')
	
if retcode == 0:
	pb.push_file(**task_output_data, title=settings['command_done_title'])
else:
	pb.push_file(**task_output_data, title=settings['command_error_title'], body='Command failed with errorcode:  ' + str(retcode) + '.  Output to follow')
开发者ID:Pyredrid,项目名称:NotifyWhenDone,代码行数:32,代码来源:nwd.py


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