Skip to content

Commit

Permalink
Only initialize the Bugzilla connection when needed
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
  • Loading branch information
puiterwijk committed Sep 28, 2016
1 parent f340915 commit 950eee2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions bodhi/server/bugs.py
Expand Up @@ -53,17 +53,26 @@ class InvalidComment(Exception):
class Bugzilla(BugTracker):

def __init__(self):
self._bz = None

def _connect(self):
user = config.get('bodhi_email')
password = config.get('bodhi_password', None)
url = config.get("bz_server")
log.info("Using BZ URL %s" % url)
if user and password:
self.bz = bugzilla.Bugzilla(url=url,
user=user, password=password,
cookiefile=None, tokenfile=None)
self._bz = bugzilla.Bugzilla(url=url,
user=user, password=password,
cookiefile=None, tokenfile=None)
else:
self.bz = bugzilla.Bugzilla(url=url,
cookiefile=None, tokenfile=None)
self._bz = bugzilla.Bugzilla(url=url,
cookiefile=None, tokenfile=None)

@property
def bz(self):
if self._bz is None:
self._connect()
return self._bz

def get_url(self, bug_id):
return "%s/show_bug.cgi?id=%s" % (config['bz_baseurl'], bug_id)
Expand Down

0 comments on commit 950eee2

Please sign in to comment.