##// END OF EJS Templates
subscribers: use shlex in the async-subscriber directly
milka -
r4582:5c8aeb25 stable
parent child Browse files
Show More
@@ -48,7 +48,7 b' def includeme(config):'
48 48
49 49 # If a reload command is set add a subscriber to execute it on
50 50 # configuration changes.
51 reload_cmd = shlex.split(settings[config_keys.reload_command])
51 reload_cmd = settings[config_keys.reload_command]
52 52 if reload_cmd:
53 53 reload_timeout = settings[config_keys.reload_timeout] or None
54 54 reload_subscriber = AsyncSubprocessSubscriber(
@@ -18,6 +18,8 b''
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20 import io
21 import shlex
22
21 23 import math
22 24 import re
23 25 import os
@@ -357,10 +359,16 b' class AsyncSubscriber(Subscriber):'
357 359 class AsyncSubprocessSubscriber(AsyncSubscriber):
358 360 """
359 361 Subscriber that uses the subprocess32 module to execute a command if an
360 event is received. Events are handled asynchronously.
362 event is received. Events are handled asynchronously::
363
364 subscriber = AsyncSubprocessSubscriber('ls -la', timeout=10)
365 subscriber(dummyEvent) # running __call__(event)
366
361 367 """
362 368
363 369 def __init__(self, cmd, timeout=None):
370 if not isinstance(cmd, (list, tuple)):
371 cmd = shlex.split(cmd)
364 372 super(AsyncSubprocessSubscriber, self).__init__()
365 373 self._cmd = cmd
366 374 self._timeout = timeout
@@ -384,6 +392,6 b' class AsyncSubprocessSubscriber(AsyncSub'
384 392 log.exception('Error while executing command.')
385 393 if e.output:
386 394 log.error('Command output: %s', e.output)
387 except:
395 except Exception:
388 396 log.exception(
389 397 'Exception while executing command %s.', cmd)
General Comments 0
You need to be logged in to leave comments. Login now