Skip to content

Commit 2e36c40

Browse files
committed
Raise login errors from XMLRPC (bz 1086879)
So you actually get warnings when your account is locked
1 parent c7fc9c1 commit 2e36c40

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

bin/bugzilla

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,11 +1138,12 @@ def main(bzinstance=None):
11381138
global_opt.password = getpass.getpass()
11391139
sys.stdout.write('Logging in... ')
11401140
sys.stdout.flush()
1141-
if bz.login(global_opt.user, global_opt.password):
1141+
try:
1142+
bz.login(global_opt.user, global_opt.password)
11421143
print('Authorization cookie received.')
11431144
sys.exit(0)
1144-
else:
1145-
print('failed.')
1145+
except bugzilla.BugzillaError:
1146+
print(str(sys.exc_info()[1]))
11461147
sys.exit(1)
11471148

11481149
# Set up authentication

bugzilla/base.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ def login(self, user=None, password=None):
474474
logged_in attribute to True, if successful.
475475
476476
If user is not set, the value of Bugzilla.user will be used. If *that*
477-
is not set, ValueError will be raised.
477+
is not set, ValueError will be raised. If login fails, BugzillaError
478+
will be raised.
478479
479480
This method will be called implicitly at the end of connect() if user
480481
and password are both set. So under most circumstances you won't need
@@ -491,14 +492,14 @@ def login(self, user=None, password=None):
491492
raise ValueError("missing password")
492493

493494
try:
494-
r = self._login(self.user, self.password)
495+
ret = self._login(self.user, self.password)
495496
self.logged_in = True
496-
log.info("login successful - dropping password from memory")
497497
self.password = ''
498+
log.info("login successful for user=%s", self.user)
499+
return ret
498500
except Fault:
499-
r = False
500-
501-
return r
501+
e = sys.exc_info()[1]
502+
raise BugzillaError("Login failed: %s" % str(e.faultString))
502503

503504
def logout(self):
504505
'''Log out of bugzilla. Drops server connection and user info, and

0 commit comments

Comments
 (0)