From a7897d1aee473b7511d161831fb0a00f074486a2 Mon Sep 17 00:00:00 2001 From: mugdhadhole1 Date: Mon, 16 Dec 2024 16:35:04 +0530 Subject: [PATCH] Implemented the review changes --- lobster/tools/codebeamer/codebeamer.py | 41 ++++++++++++-------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/lobster/tools/codebeamer/codebeamer.py b/lobster/tools/codebeamer/codebeamer.py index ec0ada2..467858d 100755 --- a/lobster/tools/codebeamer/codebeamer.py +++ b/lobster/tools/codebeamer/codebeamer.py @@ -162,20 +162,19 @@ def get_query(mh, cb_config, query): total_items = None while total_items is None or len(rv) < total_items: - print("Fetching page %u of query..." % page_id) - if query is not None: - if isinstance(query, int): - url = ("%s/reports/%u/items?page=%u&pageSize=%u" % - (cb_config["base"], - query, - page_id, - cb_config["page_size"])) - elif isinstance(query, str): - url = ("%s/items/query?queryString=%s" % - (cb_config["base"], - query)) - data = query_cb_single(cb_config, url) - assert len(data) == 4 + print("Fetching page %u of query..." % page_id) + if isinstance(query, int): + url = ("%s/reports/%u/items?page=%u&pageSize=%u" % + (cb_config["base"], + query, + page_id, + cb_config["page_size"])) + elif isinstance(query, str): + url = ("%s/items/query?queryString=%s" % + (cb_config["base"], + query)) + data = query_cb_single(cb_config, url) + assert len(data) == 4 if page_id == 1 and len(data["items"]) == 0: print("This query doesn't generate items. Please check:") @@ -539,19 +538,17 @@ def main(): if isinstance(options.import_query, int): query = int(options.import_query) if query < 1: - raise ValueError("query_string must be a positive integer" - "or valid string") + ap.error("query_string must be a positive integer") elif isinstance(options.import_query, str): if options.import_query.startswith("-"): - raise ValueError("query_string must be a positive integer" - "or valid string") + ap.error("query_string must be a positive integer" + " or valid string") elif options.import_query.isdigit(): query = int(options.import_query) if query < 1: - raise ValueError("query_string must be a positive integer" - "or valid string") - elif isinstance(options.import_query, str): - query = str(options.import_query) + ap.error("query_string must be a positive integer") + else: + query = str(options.import_query) except ValueError as e: ap.error(str(e))