diff --git a/alcli/alertlogic_cli.py b/alcli/alertlogic_cli.py index cdbdb3c..6a662a7 100755 --- a/alcli/alertlogic_cli.py +++ b/alcli/alertlogic_cli.py @@ -11,6 +11,7 @@ import argparse import re import pydoc +import shutil from urllib.parse import urlparse from collections import OrderedDict @@ -68,8 +69,9 @@ def cli_pager(text): def get_cli_pager(): if sys.platform == 'win32': return lambda text: pydoc.pipepager(text, 'more /C') - if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0: + if shutil.which('less') is not None: return lambda text: pydoc.pipepager(text, 'less -R') + return lambda text: print(text) class AlertLogicCLI(object): def __init__(self): diff --git a/alcli/clihelp.py b/alcli/clihelp.py index b082c65..146a4b3 100644 --- a/alcli/clihelp.py +++ b/alcli/clihelp.py @@ -6,6 +6,7 @@ import json import textwrap import itertools +import shutil from almdrlib.session import Session from almdrlib.region import Region from almdrlib.region import Residency @@ -42,11 +43,7 @@ def get_param_type(spec): f'Unsupported parameter type. {json.dumps(spec, indent=2)}') class FormatHelp: - if sys.platform == 'win32': - BOLD = '' - UNDERLINE = '' - END = '' - elif hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0: + if shutil.which('less') is not None: BOLD = '\033[1m' UNDERLINE = '\033[4m' END = '\033[0m'