commit 1ff26cb7eb7f3025a60755897b79ee09908d8cfc
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Mon Nov 24 11:24:52 2014 +0100
Adjust the call via FASCLIENT
As the FAS client stores its cookie on disk, it is not necessary to ask
for the user's credentials every time, instead we can ask them only when
FAS says we need to.
pkgdb2client/utils.py | 18 +++++++-----------
1 files changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/pkgdb2client/utils.py b/pkgdb2client/utils.py
index 3c7ee00..02957e6 100644
--- a/pkgdb2client/utils.py
+++ b/pkgdb2client/utils.py
@@ -136,7 +136,13 @@ def is_packager(user):
if '@' in user:
fas_user = __get_fas_user_by_email(user.strip())
else:
- fas_user = FASCLIENT.person_by_username(user)
+ try:
+ fas_user = FASCLIENT.person_by_username(user)
+ except AuthError:
+ username, password = pkgdb2client.ask_password()
+ FASCLIENT.username = username
+ FASCLIENT.password = password
+ fas_user = FASCLIENT.person_by_username(user)
return fas_user \
and 'packager' in fas_user['group_roles'] \
@@ -155,11 +161,6 @@ def check_package_creation(info, bugid):
'''
messages = []
- if not FASCLIENT.username:
- username, password = pkgdb2client.ask_password()
- FASCLIENT.username = username
- FASCLIENT.password = password
-
bug = get_bug(bugid)
# Check if the title of the bug fits the expectations
@@ -225,11 +226,6 @@ def check_branch_creation(pkgdbclient, pkg_name, clt_name, user):
)
# Check if user is a packager
- if not FASCLIENT.username:
- username, password = pkgdb2client.ask_password()
- FASCLIENT.username = username
- FASCLIENT.password = password
-
if not is_packager(user):
messages.append(' ! User {0} is not a packager'.format(user))