Author: adc
Date: Mon Sep 2 05:38:32 2013
New Revision: 1519341
URL: http://svn.apache.org/r1519341
Log:
Check if option exists instead of catching exception
Modified:
labs/panopticon/src/asf/utils/auth.py
labs/panopticon/src/asf/utils/config.py
Modified: labs/panopticon/src/asf/utils/auth.py
URL:
http://svn.apache.org/viewvc/labs/panopticon/src/asf/utils/auth.py?rev=1519341&r1=1519340&r2=1519341&view=diff
==============================================================================
--- labs/panopticon/src/asf/utils/auth.py (original)
+++ labs/panopticon/src/asf/utils/auth.py Mon Sep 2 05:38:32 2013
@@ -119,10 +119,10 @@ def clear_username_from_store():
def get_username(use_store=False):
if use_store:
- with load_config(AUTH_SECTIONS, AUTH_CONFIG_DEFAULTS) as config:
- try:
+ with load_config(sections=AUTH_SECTIONS,
defaults=AUTH_CONFIG_DEFAULTS) as config:
+ if config.has_option(AUTH_SECTION, 'username'):
username = config.get(AUTH_SECTION, 'username')
- except NoOptionError:
+ else:
username = raw_input("Username [%s]: " % getpass.getuser())
if not username:
username = getpass.getuser()
Modified: labs/panopticon/src/asf/utils/config.py
URL:
http://svn.apache.org/viewvc/labs/panopticon/src/asf/utils/config.py?rev=1519341&r1=1519340&r2=1519341&view=diff
==============================================================================
--- labs/panopticon/src/asf/utils/config.py (original)
+++ labs/panopticon/src/asf/utils/config.py Mon Sep 2 05:38:32 2013
@@ -34,6 +34,9 @@ class load_config(object):
if not self.config.has_section(section):
self.config.add_section(section)
+ def has_option(self, section, option):
+ return self.config.has_option(section, option)
+
def get(self, section, option, raw=False, variables=None):
return self.config.get(section, option, raw, variables)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]