From a476de81a8de444ed5cea4a5dcd88f13578384ca Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 4 Jan 2018 16:11:54 +0100 Subject: [PATCH] Fixed procedure execution code --- platypush/__init__.py | 6 ++++++ platypush/__main__.py | 9 ++------- platypush/message/request/__init__.py | 5 +++-- platypush/pusher/__init__.py | 10 ++++++++++ platypush/pusher/__main__.py | 13 ++----------- setup.py | 4 ++-- 6 files changed, 25 insertions(+), 22 deletions(-) diff --git a/platypush/__init__.py b/platypush/__init__.py index 8891ac8ef1..8cb2f61c17 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 38caff4e55..30fd0e9738 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 5bc1a0160e..15fb5b4c4e 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 ba1c0c6a7c..2c0e1e48d2 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 34bdf2b544..19b73df623 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 470a31698b..4242c03692 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 = [