From c44966e6154f87d9850d747053eefb9d63b121e5 Mon Sep 17 00:00:00 2001 From: surya teja reddy valluri Date: Mon, 10 Dec 2018 07:51:53 -0800 Subject: [PATCH] Added support for legacy noresults --- library/snow_record_find.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/library/snow_record_find.py b/library/snow_record_find.py index bab15bd..96906fd 100644 --- a/library/snow_record_find.py +++ b/library/snow_record_find.py @@ -122,11 +122,12 @@ HAS_PYSNOW = False try: import pysnow + from pysnow.legacy_exceptions import NoResults as LegacyNoResults from pysnow.exceptions import NoResults HAS_PYSNOW = True except ImportError: - pass + pass class BuildQuery(object): @@ -249,13 +250,18 @@ def run_module(): else: res = record.get_multiple(limit=module.params['max_records'], order_by=[module.params['order_by']]) - except: + except Exception as detail: module.fail_json(msg='Failed to find record: {0}'.format(str(detail)), **result) try: result['record'] = list(res) except NoResults: - result['record'] = [] + result['record'] = list() + except LegacyNoResults: + result['record'] = list() + + if len(result['record']) == 0: + result['record'] = list() module.exit_json(**result)