leif pushed a commit to branch master.

http://git.enlightenment.org/apps/econnman.git/commit/?id=4593c1e7ec47b33bf62872403758dd1bf4b32479

commit 4593c1e7ec47b33bf62872403758dd1bf4b32479
Author: Matthias Wauer <matthiaswa...@googlemail.com>
Date:   Fri Jan 24 14:00:15 2014 +0100

    Catch exception when querrying config options
    
    Summary:
    Querrying config options, that are not found in the config file
    will no longer throw IOError.
    
    Test Plan:
    Configure a ieee8021x secured wifi and set one of the
    options to 'None'. Reloading the configuration (service) view will now
    work with selected (None) option.
    
    Reviewers: leif
    
    CC: FillFeile
    
    Differential Revision: https://phab.enlightenment.org/D490
---
 econnman-bin.in | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/econnman-bin.in b/econnman-bin.in
index 108d732..c58db9a 100755
--- a/econnman-bin.in
+++ b/econnman-bin.in
@@ -310,6 +310,11 @@ def config_get(name):
         else:
             return None
 
+def config_option_get(secname, key):
+    if configs.has_option(secname, key):
+        return configs.get(secname, key)
+    return None
+
 def config_exists(name):
     if config_get(name):
         return True
@@ -986,24 +991,28 @@ class ServiceView(ObjectView):
             self.eap_method, self.eap_method_items = self.add_segment_control(
             bx, options, self._on_eap_method)
             if cfg_sec:
-                conf_val = configs.get(cfg_sec, 'EAP')
+                conf_val = config_option_get(cfg_sec, 'EAP')
                 if conf_val == "peap":
                     self.eap_method_items["PEAP"].selected = True
                 elif conf_val == "tls":
                     self.eap_method_items["TLS"].selected = True
                 elif conf_val == "ttls":
                     self.eap_method_items["TTLS"].selected = True
+                elif conf_val == None:
+                    self.eap_method_items["None"].selected = True
 
             options = ("TLS", "MSCHAPv2", "None")
             lb = self.add_label(bx, "Phase2:")
             self.phase2, self.phase2_items = self.add_segment_control(
             bx, options, self._on_phase2)
             if cfg_sec:
-                conf_val = configs.get(cfg_sec, 'Phase2')
+                conf_val = config_option_get(cfg_sec, 'Phase2')
                 if conf_val == "tls":
                     self.phase2_items["TLS"].selected = True
                 elif conf_val == "MSCHAPV2":
                     self.phase2_items["MSCHAPv2"].selected = True
+                elif conf_val == None:
+                    self.phase2_items["None"].selected = True
 
     def add_readonly_section(self, title, fields):
         fr, bx = self.add_frame_and_box(self.box, title)

-- 


Reply via email to