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

Initial release


git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@2035 b32b6428-25c9-4566-ad07-03861ab6144f
parent af38eec2
Branches
No related tags found
No related merge requests found
from setuptools import setup,find_packages
with open('README.rst') as f:
long_description = f.read()
VERSION = "0.1"
setup(
name='xaal.pushbullet',
version=VERSION,
license='GPL License',
author='Jerome Kerdreux',
author_email='Jerome.Kerdreux@imt-atlantique.fr',
#url='',
description=('xAAL notification for pushbullet' ),
long_description=long_description,
classifiers=[
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules',
],
keywords=['xaal', 'pushbullet'],
platforms='any',
packages=find_packages(),
include_package_data=True,
install_requires=[
'xaal.lib',
'pushbullet.py',
]
)
[config]
addr = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
key = xxxxxxxx
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
from xaal.lib import Engine
from . import dev
def main():
eng = Engine()
dev.setup(eng)
eng.run()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print("Bye Bye...")
\ No newline at end of file
from xaal.lib import tools,Engine,Device
import platform
import time
import atexit
from pushbullet import Pushbullet
PACKAGE_NAME = "xaal.pushbullet"
logger = tools.get_logger(PACKAGE_NAME,'DEBUG')
push_bullet = None
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.write()
key = cfg['config'].get('key',None)
if not key:
logger.info('Please setup the Pushbullet Key')
return
push_bullet = Pushbullet(key)
info = "%s@%s" % (PACKAGE_NAME,platform.node())
dev = Device("notification.pushbullet")
dev.address = cfg['config']['addr']
dev.product_id = "Pushbullet Notification device"
dev.vendor_id = "IHSEV TEAM"
dev.version = 0.1
dev.info = info
dev.add_method('notify',notify)
engine.add_device(dev)
notify(info,'started')
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)
def setup(engine):
register_device(engine)
return True
from xaal.lib import Device,Engine,tools
import sys
# try to find the same address
cfg = tools.load_cfg_or_die('xaal.pushbullet')
target = cfg['config']['addr']
dev = Device("test.basic",tools.get_random_uuid())
eng = Engine()
eng.add_device(dev)
eng.start()
title = sys.argv[1]
msg = sys.argv[2]
eng.send_request(dev,[target,],'notify',{'title' : title,'msg' : msg})
eng.loop()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment