From 3a9a4a9596c9eda46f8010e0a90328844abfb873 Mon Sep 17 00:00:00 2001 From: Pavel Trakhtman Date: Tue, 14 Apr 2020 16:15:25 -0500 Subject: [PATCH] Fixed a bug when alcli crashed on an empty response. Updated to use the lastest alertlogic-sdk-python. Fixed to use correct flag with 'more' on windows --- alcli/__init__.py | 2 +- alcli/alertlogic_cli.py | 7 +++++-- requirements.txt | 2 +- setup.py | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/alcli/__init__.py b/alcli/__init__.py index e2ead38..b7c97e3 100644 --- a/alcli/__init__.py +++ b/alcli/__init__.py @@ -1,2 +1,2 @@ -__version__ = '1.0.10' +__version__ = '1.0.13' __author__ = 'Alert Logic, Inc.' diff --git a/alcli/alertlogic_cli.py b/alcli/alertlogic_cli.py index 8c61c12..dbb6204 100644 --- a/alcli/alertlogic_cli.py +++ b/alcli/alertlogic_cli.py @@ -55,7 +55,7 @@ def cli_pager(text): def get_cli_pager(): if sys.platform == 'win32': - return lambda text: pydoc.pipepager(text, 'more -C') + return lambda text: pydoc.pipepager(text, 'more /C') if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0: return lambda text: pydoc.pipepager(text, 'less -R') @@ -172,7 +172,10 @@ def __call__(self, args, parsed_globals): # Remove optional arguments that haven't been supplied op_args = {k:self._encode(operation, k, v) for (k,v) in kwargs.items() if v is not None} res = operation(**op_args) - self._print_result(res.json(), parsed_globals.query) + try: + self._print_result(res.json(), parsed_globals.query) + except JSONDecodeError: + print(f"status code: {res.status_code}") @property def client(self): diff --git a/requirements.txt b/requirements.txt index 0e5ad29..b92b75b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -alertlogic-sdk-python>=1.0.14 +alertlogic-sdk-python>=1.0.15 jmespath>=0.9.4 certifi==2019.11.28 chardet==3.0.4 diff --git a/setup.py b/setup.py index 4588c7f..c6021c0 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ history = history_file.read() requirements = [ - 'alertlogic-sdk-python>=1.0.14', + 'alertlogic-sdk-python>=1.0.15', 'configparser>=4.0.2', 'pyyaml==5.1.2', 'jmespath>=0.9.4'