diff --git a/platypush/__init__.py b/platypush/__init__.py index 8891ac8e..8cb2f61c 100644 --- a/platypush/__init__.py +++ b/platypush/__init__.py @@ -119,5 +119,11 @@ class Daemon(object): self.stop_app() +def main(): + print('Starting platypush v.{}'.format(__version__)) + app = Daemon.build_from_cmdline(sys.argv[1:]) + app.start() + + # vim:sw=4:ts=4:et: diff --git a/platypush/__main__.py b/platypush/__main__.py index 38caff4e..30fd0e97 100644 --- a/platypush/__main__.py +++ b/platypush/__main__.py @@ -1,11 +1,6 @@ -import sys - -from platypush import Daemon, __version__ - -print('Starting platypush v.{}'.format(__version__)) -app = Daemon.build_from_cmdline(sys.argv[1:]) -app.start() +from platypush import main +main() # vim:sw=4:ts=4:et: diff --git a/platypush/message/request/__init__.py b/platypush/message/request/__init__.py index 5bc1a016..15fb5b4c 100644 --- a/platypush/message/request/__init__.py +++ b/platypush/message/request/__init__.py @@ -53,9 +53,10 @@ class Request(Message): def _execute_procedure(self, *args, **kwargs): - from config import Config + from platypush.config import Config + from platypush.procedure import Procedure - logging.info('Executing procedure request: {}'.format(procedure)) + logging.info('Executing procedure request: {}'.format(self.action)) proc_name = self.action.split('.')[-1] proc_config = Config.get_procedures()[proc_name] proc = Procedure.build(name=proc_name, requests=proc_config, backend=self.backend, id=self.id) diff --git a/platypush/pusher/__init__.py b/platypush/pusher/__init__.py index ba1c0c6a..2c0e1e48 100644 --- a/platypush/pusher/__init__.py +++ b/platypush/pusher/__init__.py @@ -176,5 +176,15 @@ class Pusher(object): response_timeout=timeout) +def main(): + opts = Pusher.parse_build_args(sys.argv[1:]) + pusher = Pusher(config_file=opts.config, backend=opts.backend) + + if opts.type == 'event': + pusher.send_event(target=opts.target, type=opts.event, **opts.args) + else: + pusher.send_request(target=opts.target, action=opts.action, timeout=opts.timeout, **opts.args) + + # vim:sw=4:ts=4:et: diff --git a/platypush/pusher/__main__.py b/platypush/pusher/__main__.py index 34bdf2b5..19b73df6 100644 --- a/platypush/pusher/__main__.py +++ b/platypush/pusher/__main__.py @@ -1,15 +1,6 @@ -import sys - -from . import Pusher - -opts = Pusher.parse_build_args(sys.argv[1:]) -pusher = Pusher(config_file=opts.config, backend=opts.backend) - -if opts.type == 'event': - pusher.send_event(target=opts.target, type=opts.event, **opts.args) -else: - pusher.send_request(target=opts.target, action=opts.action, timeout=opts.timeout, **opts.args) +from platypush.pusher import main +main() # vim:sw=4:ts=4:et: diff --git a/setup.py b/setup.py index 470a3169..4242c036 100755 --- a/setup.py +++ b/setup.py @@ -43,8 +43,8 @@ setup( packages = find_packages(), entry_points = { 'console_scripts': [ - 'platypush=platypush.__main__', - 'pusher=platypush.pusher.__main__', + 'platypush=platypush:main', + 'pusher=platypush.pusher:main', ], }, data_files = [