From 4c4d34b2b0d70e0c92f568a0080eff0df49f096f Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Wed, 25 Feb 2015 09:35:49 -0500 Subject: Handle missing launchpadlib gracefully The use of launchpadlib should not be required for tempest-lib, however because we wanted to expose the skip_tracker as an entry point and package it with the library an import to launchpadlib was needed in the packaged source, which normally should require an entry in the requirements file. This commit addresses that by making the launchpadlib use not mandatory. The script will check if launchpadlib is available and if it isn't the skip tracker will just exit after it scans for the bug list. Change-Id: I59814346e899e366734caaf757eb2d8fe5ecbcf7 --- tempest_lib/cmd/skip_tracker.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tempest_lib/cmd/skip_tracker.py b/tempest_lib/cmd/skip_tracker.py index b823a1e..b5c9b95 100755 --- a/tempest_lib/cmd/skip_tracker.py +++ b/tempest_lib/cmd/skip_tracker.py @@ -25,7 +25,10 @@ import logging import os import re -from launchpadlib import launchpad +try: + from launchpadlib import launchpad +except ImportError: + launchpad = None LPCACHEDIR = os.path.expanduser('~/.launchpadlib/cache') @@ -114,9 +117,14 @@ def main(): duplicates = [] info("Total bug skips found: %d", len(results)) info("Total unique bugs causing skips: %d", len(unique_bugs)) - lp = launchpad.Launchpad.login_anonymously('grabbing bugs', - 'production', - LPCACHEDIR) + if launchpad is not None: + lp = launchpad.Launchpad.login_anonymously('grabbing bugs', + 'production', + LPCACHEDIR) + else: + print("To check the bug status launchpadlib should be installed") + exit(1) + for bug_no in unique_bugs: bug = lp.bugs[bug_no] duplicate = bug.duplicate_of_link -- cgit v1.2.1