From fe23d19585ac3ae1c00f79b658e537eb61cfb494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jero=CC=81nimo=20Albi?= Date: Fri, 7 Apr 2017 20:35:26 +0200 Subject: [PATCH] Fixed runner to read from stdinput only when `--action` is present --- katana/sdk/runner.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/katana/sdk/runner.py b/katana/sdk/runner.py index 36edd62..2cc2fce 100644 --- a/katana/sdk/runner.py +++ b/katana/sdk/runner.py @@ -335,16 +335,10 @@ def run(self, **kwargs): self._args = kwargs - # Get input message with action name and payload if available + # Standard input is read only when action name is given message = {} - contents = click.get_text_stream('stdin', encoding='utf8').read() - if contents: - if not kwargs.get('action'): - LOG.error('Action name is missing') - os._exit(EXIT_ERROR) - - # Add action name to message - message['action'] = kwargs['action'] + if kwargs.get('action'): + contents = click.get_text_stream('stdin', encoding='utf8').read() # Add JSON file contents to message try: @@ -353,6 +347,9 @@ def run(self, **kwargs): LOG.exception('Stdin input value is not valid JSON') os._exit(EXIT_ERROR) + # Add action name to message + message['action'] = kwargs['action'] + # Initialize component logging only when `quiet` argument is False, or # if an input message is given init logging only when debug is True if not kwargs.get('quiet'):