Skip to content
Snippets Groups Projects
Commit 39621222 authored by jkerdreu's avatar jkerdreu
Browse files

Added multi-keys support

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@2212 b32b6428-25c9-4566-ad07-03861ab6144f
parent 5c332830
No related branches found
No related tags found
No related merge requests found
......@@ -10,21 +10,22 @@ PACKAGE_NAME = "xaal.pushbullet"
logger = logging.getLogger(PACKAGE_NAME)
push_bullet = None
push_bullets = []
def register_device(engine):
global push_bullet
cfg = tools.load_cfg(PACKAGE_NAME)
if not cfg:
logger.info('Missing config file, building a new one')
cfg = tools.new_cfg(PACKAGE_NAME)
cfg['config']['key']=''
cfg['config']['keys']=''
cfg.write()
key = cfg['config'].get('key',None)
if not key:
logger.info('Please setup the Pushbullet Key')
keys = cfg['config'].get('keys',None)
if not keys:
logger.info('Please setup the Pushbullet keys')
return
push_bullet = Pushbullet(key)
for k in keys:
push_bullets.append(Pushbullet(k))
info = "%s@%s" % (PACKAGE_NAME,platform.node())
dev = Device("notification.pushbullet")
dev.address = cfg['config']['addr']
......@@ -38,17 +39,16 @@ def register_device(engine):
atexit.register(notify,info,'shutdown..')
def notify(_title,_msg):
global push_bullet
if push_bullet:
try:
push_bullet.push_note(_title,_msg)
except Exception as err:
print("Pushbullet exception: {0}".format(err))
# some error can occur on a broken link, just try to resend
time.sleep(0.5)
push_bullet.push_note(_title,_msg)
global push_bullets
if push_bullets != []:
for pb in push_bullets:
try:
pb.push_note(_title,_msg)
except Exception as err:
print("Pushbullet exception: {0}".format(err))
# some error can occur on a broken link, just try to resend
time.sleep(0.5)
pb.push_note(_title,_msg)
def setup(engine):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment