Skip to content
Permalink
Browse files

Merge branch 'fall-back-to-less' of https://github.com/htgoebel/debops

…into htgoebel-fall-back-to-less
  • Loading branch information...
drybjed committed Sep 8, 2019
2 parents 7a15ccf + 39e4c82 commit 2cc2f33a159736d5da0ec7a2f5303f189894c3a1
Showing with 15 additions and 6 deletions.
  1. +15 −6 bin/debops-defaults
@@ -96,13 +96,22 @@ def main(role_list):
config = read_config(project_root)
playbooks_path = find_playbookpath(config, project_root, required=True)

# Make sure required commands are present
require_commands('view')

if sys.stdout.isatty():
# Check if one of the output commands is present
sys.stdout = io.BytesIO() # suppress error message, if any
for cmd_args in (('view', '+set ft=yaml', '-'),
('less', '-'),
('more', '-')):
try:
require_commands(cmd_args[0])
break
except SystemExit:
# this command was not found
cmd_args = None
sys.stdout = sys.__stdout__

if cmd_args and sys.stdout.isatty():
# if script is run as standalone, redirect to view
view = subprocess.Popen(['view', '+set ft=yaml', '-'],
stdin=subprocess.PIPE)
view = subprocess.Popen(cmd_args, stdin=subprocess.PIPE)
try:
aggregate_defaults(playbooks_path, role_list, view.stdin)
except IOError as e:

0 comments on commit 2cc2f33

Please sign in to comment.
You can’t perform that action at this time.