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


Python Pushbullet.push_note方法代码示例

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


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

示例1: checkupsstatus

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

示例2: main

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_note [as 别名]
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()
开发者ID:jaemk,项目名称:pushpy,代码行数:30,代码来源:pushy.py

示例3: push

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_note [as 别名]
def push(text: str, details: str, r: praw) -> None:
    """
    Push a message to computer
    :param text: MNT or WNT
    :param details: Match details
    :param r: PRAW instance
    :return: None
    """
    try:
        from pushbullet import Pushbullet
        with open('token.txt') as files:
            token = files.read().strip()
        pb = Pushbullet(token)
        try:
            lst = text.split('?')
            pb.push_note('{} match today at {} on {}'.format(details, lst[4], lst[3]),
                         '', device=pb.get_device('iPhone'))
        except IndexError:
            pb.push_note('{}{}'.format(text, details),
                         '', device=pb.get_device('iPhone'))

    except ImportError:
        lst = text.split('?')
        r.send_message('RedRavens', '{} Match Today'.format(details),
                       '{} match today at {} on {}'.format(details, lst[4], lst[3]))
开发者ID:Red-Ravens,项目名称:soccer-updater,代码行数:27,代码来源:updater.py

示例4: _send_message

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

示例5: send_pushbullet

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_note [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

示例6: cancel

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_note [as 别名]
 def cancel(self, alert, options):
     api_key = self.context.client.call_sync('alert.emitter.pushbullet.get_api_key')
     pb = Pushbullet(api_key)
     pb.push_note(
         'Alert on {0} canceled: {1}'.format(
             socket.gethostname(),
             alert['title']
         ),
         alert['description']
     )
开发者ID:erinix,项目名称:middleware,代码行数:12,代码来源:PushbulletEmitter.py

示例7: PushBulletHandler

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_note [as 别名]
class PushBulletHandler(logging.Handler):

    def __init__(self, api_key, title='', email=None, level=logging.WARNING):
        super().__init__(level)
        self.client = Pushbullet(api_key)
        self.title = title
        self.email = email

    def emit(self, record):
        try:
            self.client.push_note(
                title=self.title, body=self.format(record), email=self.email
            )
        except Exception:
            self.handleError(record)
开发者ID:skoslowski,项目名称:LANtopPy,代码行数:17,代码来源:utils.py

示例8: on_notification

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

示例9: notify

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_note [as 别名]
def notify(game, team, seconds, minutes, pushbullet, pushbullet_key, force):
    team = team.lower().strip()
    if pushbullet:
        if not pushbullet_key:
            pushbullet_key = os.environ.get('PUSHBULLET_API', '')
        if not pushbullet_key:
            click.secho('To use pushbullet notification supply --pushbulet-key '
                        'or enviroment variable PUSHBULLET_API', err=True, fg='red')
            return
        try:
            from pushbullet import Pushbullet
        except ImportError:
            click.secho('To use pushbullet notification install pusbullet.py package;'
                        ' pip install pushbullet.py', err=True, fg='red')
            return

    if minutes:
        seconds = minutes * 60
    matches = download_matches(game)
    re_team = re.compile(team, flags=re.I)
    for match in matches:
        if int(match['time_secs']) > int(seconds):
            continue
        if re_team.match(match['t1']) or re_team.match(match['t2']):
            # already in history?
            if not force:
                with open(HISTORY_LOCATION, 'r') as f:
                    if match.id in f.read():
                        continue
            # notify
            title = "{} vs {} in {}".format(match['t1'], match['t2'], match['time'])
            body = match.get('stream') or match['url']
            if pushbullet:
                push = Pushbullet(pushbullet_key)
                push.push_note(title, body)
            else:
                # The if check below is for fixing notify-send to work with cron
                # cron notify-send requires $DBUS_SESSION_BUS_ADDRESS to be set
                # as per http://unix.stackexchange.com/questions/111188
                subprocess.call('if [ -r "$HOME/.dbus/Xdbus" ]; '
                                'then . $HOME/.dbus/Xdbus; '
                                'fi && notify-send "{}" "{}"'.format(title, body),
                                shell=True)
            # add to history
            with open(HISTORY_LOCATION, 'a') as f:
                f.write('{}\n'.format(match.id))
开发者ID:Granitas,项目名称:gosuticker,代码行数:48,代码来源:cli.py

示例10: post

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

示例11: check_webserver

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_note [as 别名]
def check_webserver():
	print '\ncheck_webserver()'
	try:
		code_ws = urllib.urlopen("http://localhost/index.php").getcode()
		
		if( code_ws != '200') :
			logmessage = " OK, server web is running"
		else :
			global ACCESS_TOKEN
			pb = Pushbullet(ACCESS_TOKEN)
			logmessage = time.strftime("%Y-%m-%d %H:%M:%S") + "\n Domini - Erreur : serveur web est arrete"
			push = pb.push_note("Domini", logmessage)	
	except:
		logmessage = time.strftime("%Y-%m-%d %H:%M:%S") + "\n Domini - Erreur : etat serveur web inconnu"
		push = pb.push_note("Domini", logmessage)
		
	print logmessage
	syslog.syslog(logmessage)	
开发者ID:minbiocabanon,项目名称:DoMini,代码行数:20,代码来源:pySentinelle.py

示例12: send_push

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

示例13: PushBulletRoute

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_note [as 别名]
class PushBulletRoute(Route):
    """SmartHome using pushbullet."""

    def __init__(self, cfg):
        super(PushBulletRoute).__init__(cfg)
        
        self.lastFetch = time.time()
        self.apiKey = self.cfg.get('global', 'api_key')
        self.pb = Pushbullet(self.apiKey)

    def run(self):
        try:
            deviceIden = self.cfg.get('global', 'device_iden')
        except NoOptionError:
            deviceIden = self.pb.new_device('SmartHome').device_iden
            self.cfg.set('global', 'device_iden', deviceIden)
            with open(CONFIG_FILE, 'w') as f:
                self.cfg.write(f)

        def on_push(msg):
            journal.send('Got message: ' + json.dumps(msg))
            try:
                pushes = self.pb.get_pushes(self.lastFetch)
                journal.send('Got pushes: ' + json.dumps(pushes))
                self.lastFetch = time.time()
                if type(pushes) is types.TupleType and len(pushes)>1 \
                        and type(pushes[1]) is types.ListType:
                    for push in pushes[1]:
                        journal.send('Check push: ' + json.dumps(push))
                        if push.has_key('target_device_iden') and push['target_device_iden'] == deviceIden:
                            cmd = json.loads(push['body'])
                            self.home.followCommand(cmd)
                            fromIden = push['source_device_iden']
                            fromDevice = self.getDevice(fromIden)
                            if fromDevice is None:
                                journal.send('get_status: Cannot find device with iden "' + fromIden + '"', PRIORITY=journal.LOG_ERR)
                                return
                            self.pb.push_note('status', self.home.getStatus(), fromDevice)
            except (PushbulletError, IOError, ValueError, KeyError), e:
                journal.send(str(e), PRIORITY=journal.LOG_ERR)

        lsr = Listener(Account(self.apiKey), on_push)
        lsr.run()
开发者ID:xbot,项目名称:SmartHome,代码行数:45,代码来源:main.py

示例14: new_transaction

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_note [as 别名]
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
开发者ID:Manoj-nathwani,项目名称:my-mondo,代码行数:12,代码来源:app.py

示例15: Error_loop

# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_note [as 别名]
def Error_loop():
	# un peu bourrin : on boucle sur le message d'erreur + envoie d'info tant que le pb n'est pas resolu
	while True :
		logmessage = time.strftime("%Y-%m-%d %H:%M:%S") + "Alarme en mode ERROR !"
		print logmessage
		syslog.syslog(logmessage)
		# send message through pushbullet to user
		# initialize pushbullet 
		pb = Pushbullet(ACCESS_TOKEN)
		push = pb.push_note("Domini - Alarme", logmessage)
		time.sleep(600)
开发者ID:minbiocabanon,项目名称:DoMini,代码行数:13,代码来源:pyCaptureCam.py


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