commit:     2b265fb79f78542af6d01aec4f79947a1416af30
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct  9 17:54:43 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Oct  9 17:54:43 2014 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=2b265fb7

config.py: Adds exception handling for setting env vars

In some cases when setting environment variables you can encounter
an issue where you are trying to set a config value based on the
the environment variable and you run into a runtime error. One
notable situation is when you try to run webapp-config --envall
while running py2.7, you will run into an interpolation issue if
one of your environment variables includes a sort of interpolation
syntax such as: %s.

---
 WebappConfig/config.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index b708ee0..1b9ebde 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -873,9 +873,12 @@ class Config:
 
                     OUT.debug('Adding environment variable', 8)
 
-                    self.config.set('USER',
-                                    key.lower(),
-                                    value)
+                    try:
+                        self.config.set('USER',
+                                        key.lower(),
+                                        value)
+                    except ValueError:
+                        pass
 
         if ('define' in options and
               options['define']):

Reply via email to