# HG changeset patch # User Milka Kuzminski # Date 2020-11-30 11:28:47 # Node ID 5c8aeb25a1a83109e6a70a404c5aab3a8f890359 # Parent f359369c976625ff14282207bf5934dacd90f00d subscribers: use shlex in the async-subscriber directly diff --git a/rhodecode/apps/svn_support/__init__.py b/rhodecode/apps/svn_support/__init__.py --- a/rhodecode/apps/svn_support/__init__.py +++ b/rhodecode/apps/svn_support/__init__.py @@ -48,7 +48,7 @@ def includeme(config): # If a reload command is set add a subscriber to execute it on # configuration changes. - reload_cmd = shlex.split(settings[config_keys.reload_command]) + reload_cmd = settings[config_keys.reload_command] if reload_cmd: reload_timeout = settings[config_keys.reload_timeout] or None reload_subscriber = AsyncSubprocessSubscriber( diff --git a/rhodecode/subscribers.py b/rhodecode/subscribers.py --- a/rhodecode/subscribers.py +++ b/rhodecode/subscribers.py @@ -18,6 +18,8 @@ # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ import io +import shlex + import math import re import os @@ -357,10 +359,16 @@ class AsyncSubscriber(Subscriber): class AsyncSubprocessSubscriber(AsyncSubscriber): """ Subscriber that uses the subprocess32 module to execute a command if an - event is received. Events are handled asynchronously. + event is received. Events are handled asynchronously:: + + subscriber = AsyncSubprocessSubscriber('ls -la', timeout=10) + subscriber(dummyEvent) # running __call__(event) + """ def __init__(self, cmd, timeout=None): + if not isinstance(cmd, (list, tuple)): + cmd = shlex.split(cmd) super(AsyncSubprocessSubscriber, self).__init__() self._cmd = cmd self._timeout = timeout @@ -384,6 +392,6 @@ class AsyncSubprocessSubscriber(AsyncSub log.exception('Error while executing command.') if e.output: log.error('Command output: %s', e.output) - except: + except Exception: log.exception( 'Exception while executing command %s.', cmd)