incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1488847 - in /incubator/public/trunk/tools/src/asf/utils: auth.py test.py
Date Mon, 03 Jun 2013 05:01:56 GMT
Author: adc
Date: Mon Jun  3 05:01:56 2013
New Revision: 1488847

URL: http://svn.apache.org/r1488847
Log:
Renamed stored_credentials() to get_ stored_credentials()

Added some helpful documentation.

Modified:
    incubator/public/trunk/tools/src/asf/utils/auth.py
    incubator/public/trunk/tools/src/asf/utils/test.py

Modified: incubator/public/trunk/tools/src/asf/utils/auth.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/tools/src/asf/utils/auth.py?rev=1488847&r1=1488846&r2=1488847&view=diff
==============================================================================
--- incubator/public/trunk/tools/src/asf/utils/auth.py (original)
+++ incubator/public/trunk/tools/src/asf/utils/auth.py Mon Jun  3 05:01:56 2013
@@ -288,10 +288,19 @@ def validate_password(entry, username, c
     return False
 
 
-def stored_credentials():
+def get_stored_credentials():
+    """
+        Gets the credentials, username and password, that have been stored in
+        ~/.asf-tools.ini and the secure keychain respectively without bothering
+        to prompt the user if either credential cannot be found.
+
+        :returns: username and password
+        :rtype: tuple of str
+    """
     with load_config(AUTH_SECTIONS, AUTH_CONFIG_DEFAULTS) as config:
         username = config.get(AUTH_SECTION, 'username')
         if not username:
+            # if we don't have a username then we cannot lookup the password
             return None, None
 
     has_keychain = initialize_keychain()
@@ -301,8 +310,9 @@ def stored_credentials():
     if has_keychain:
         try:
             password = keyring.get_password(AUTH_SECTION, username)
+            return username, password
         except Exception as e:
-            return None, None
-        return username, password
+            log.warn("Unable to get password from keyring. Continuing..")
+            log.debug(e)
 
-    return None, None
+    return username, None

Modified: incubator/public/trunk/tools/src/asf/utils/test.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/tools/src/asf/utils/test.py?rev=1488847&r1=1488846&r2=1488847&view=diff
==============================================================================
--- incubator/public/trunk/tools/src/asf/utils/test.py (original)
+++ incubator/public/trunk/tools/src/asf/utils/test.py Mon Jun  3 05:01:56 2013
@@ -18,12 +18,12 @@
 #
 import nose
 
-from asf.utils.auth import stored_credentials
+from asf.utils.auth import get_stored_credentials
 
 
 def ensure_credentials_stored(function):
     def wrapped(*args, **kwargs):
-        username, password = stored_credentials()
+        username, password = get_stored_credentials()
         if not (username and password):
             raise nose.SkipTest('Credentials not stored for testing')
 



---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@incubator.apache.org
For additional commands, e-mail: cvs-help@incubator.apache.org


Mime
View raw message