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
This commit is contained in:
Matthias Wauer 2014-01-24 14:00:15 +01:00 committed by Leif Middelschulte
parent d648f6ae47
commit 4593c1e7ec
1 changed files with 11 additions and 2 deletions

View File

@ -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)