Ticket #623: 623.patch

File 623.patch, 1.6 KB (added by erikos, 15 years ago)

better error handling when reading in connections file

  • src/jarabe/model/network.py

    diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
    index bd4b7d1..2a16fbe 100644
    a b def load_connections(): 
    360360            settings.connection.uuid = uuid
    361361            nmtype = config.get(section, 'type')
    362362            settings.connection.type = nmtype
    363             autoconnect = bool(config.get(section, 'autoconnect'))
     363            try:
     364                autoconnect = config.getboolean(section, 'autoconnect')
     365            except ValueError, e:
     366                logging.error('Error reading section autoconnect: %s' % e)
     367                continue
    364368            settings.connection.autoconnect = autoconnect
    365             timestamp = int(config.get(section, 'timestamp'))
     369            try:
     370                timestamp = config.getint(section, 'timestamp')
     371            except ValueError, e:
     372                logging.error('Error reading section timestamp: %s' % e)
     373                continue
    366374            settings.connection.timestamp = timestamp
    367375
    368376            secrets = None
    def load_connections(): 
    389397                    if config.has_option(section, 'pairwise'):
    390398                        value = config.get(section, 'pairwise')
    391399                        settings.wireless_security.pairwise = value
     400                else:
     401                    logging.error('Error reading section key-mgmt: %s' %
     402                                  mgmt)
     403                    continue
    392404        except ConfigParser.Error, e:
    393405            logging.error('Error reading section: %s' % e)
    394406        else: