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
This commit is contained in:
Matthew Treinish
2015-02-25 09:35:49 -05:00
parent aa74d0fe68
commit 4c4d34b2b0

View File

@@ -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))
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