Skip to content

Commit

Permalink
Fixed runner to read from stdinput only when --action is present
Browse files Browse the repository at this point in the history
  • Loading branch information
jeronimoalbi committed Apr 7, 2017
1 parent 445b5ee commit fe23d19
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions katana/sdk/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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'):
Expand Down

0 comments on commit fe23d19

Please sign in to comment.