Ticket #1630: 0001-Refinements-of-1630.patch

File 0001-Refinements-of-1630.patch, 6.2 KB (added by erikos, 9 years ago)

Patch that addresses the issues raised by me

  • extensions/cpsection/modemconfiguration/model.py

    From df505e2faeb65a17e90935485c1c98601ff33204 Mon Sep 17 00:00:00 2001
    From: Simon Schampijer <simon@schampijer.de>
    Date: Wed, 25 Aug 2010 14:54:38 +0200
    Subject: [PATCH] Refinements of #1630
    
    - pylint cleanups
    - better error handling with loggings
    ---
     extensions/cpsection/modemconfiguration/model.py |   16 ++++++++++--
     extensions/cpsection/modemconfiguration/view.py  |   28 ++++++++++++---------
     2 files changed, 29 insertions(+), 15 deletions(-)
    
    diff --git a/extensions/cpsection/modemconfiguration/model.py b/extensions/cpsection/modemconfiguration/model.py
    index 42f7563..dbec47d 100644
    a b import gconf 
    1818import gtk
    1919import os
    2020import locale
     21import logging
     22
    2123from xml.etree.cElementTree import ElementTree
    2224from gettext import gettext as _
    2325
    def set_puk(puk): 
    7981
    8082def has_providers_db():
    8183    if not os.path.isfile(COUNTRY_CODES_PATH):
     84        logging.debug("Mobile broadband provider database: Country " \
     85                          "codes path %s not found.", COUNTRY_CODES_PATH)
    8286        return False
    8387    try:
    8488        tree = ElementTree(file=PROVIDERS_PATH)
     89    except (IOError, SyntaxError), e:
     90        logging.debug("Mobile broadband provider database: Could not read " \
     91                          "provider information %s error=%s", PROVIDERS_PATH)
     92        return False
     93    else:
    8594        elem = tree.getroot()
    8695        if elem is None or elem.get('format') != PROVIDERS_FORMAT_SUPPORTED:
     96            logging.debug("Mobile broadband provider database: Could not " \
     97                          "read provider information. %s is wrong format.",
     98                          elem.get('format'))
    8799            return False
    88100        return True
    89     except IOError:
    90         return False
     101
    91102
    92103class CountryListStore(gtk.ListStore):
    93104    COUNTRY_CODE = locale.getdefaultlocale()[0][3:5].lower()
    class PlanListStore(gtk.ListStore): 
    176187
    177188    def get_row_plan(self, row):
    178189        return self[row][1]
    179 
  • extensions/cpsection/modemconfiguration/view.py

    diff --git a/extensions/cpsection/modemconfiguration/view.py b/extensions/cpsection/modemconfiguration/view.py
    index 1d9d27f..3b03b3d 100644
    a b  
    1414# along with this program; if not, write to the Free Software
    1515# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  US
    1616
    17 import os
    18 import logging
    1917from gettext import gettext as _
    2018
    2119import gtk
    class EntryWithLabel(gtk.HBox): 
    3129    __gtype_name__ = "SugarEntryWithLabel"
    3230
    3331    def __init__(self, label_text):
    34         gtk.HBox.__init__(self, spacing=style.DEFAULT_SPACING*2)
     32        gtk.HBox.__init__(self, spacing=style.DEFAULT_SPACING * 2)
    3533
    3634        self._timeout_sid = 0
    3735        self._changed_handler = None
    class EntryWithLabel(gtk.HBox): 
    7977    def get_value(self):
    8078        raise NotImplementedError
    8179
    82     def set_value(self):
     80    def set_value(self, value):
    8381        raise NotImplementedError   
    8482
    8583    def _get_is_valid(self):
    8684        return self._is_valid
     85
    8786    is_valid = gobject.property(type=bool, getter=_get_is_valid, default=True)
    8887
     88
    8989class UsernameEntry(EntryWithLabel):
    9090    def __init__(self, model):
    9191        EntryWithLabel.__init__(self, _('Username:'))
    class UsernameEntry(EntryWithLabel): 
    9797    def set_value(self, username):
    9898        self._model.set_username(username)
    9999
     100
    100101class PasswordEntry(EntryWithLabel):
    101102    def __init__(self, model):
    102103        EntryWithLabel.__init__(self, _('Password:'))
    class PasswordEntry(EntryWithLabel): 
    108109    def set_value(self, password):
    109110        self._model.set_password(password)
    110111
     112
    111113class NumberEntry(EntryWithLabel):
    112114    def __init__(self, model):
    113115        EntryWithLabel.__init__(self, _('Number:'))
    class NumberEntry(EntryWithLabel): 
    119121    def set_value(self, number):
    120122        self._model.set_number(number)
    121123
     124
    122125class ApnEntry(EntryWithLabel):
    123126    def __init__(self, model):
    124127        EntryWithLabel.__init__(self, _('Access Point Name (APN):'))
    class ApnEntry(EntryWithLabel): 
    130133    def set_value(self, apn):
    131134        self._model.set_apn(apn)
    132135
     136
    133137class PinEntry(EntryWithLabel):
    134138    def __init__(self, model):
    135139        EntryWithLabel.__init__(self, _('Personal Identity Number (PIN):'))
    class PinEntry(EntryWithLabel): 
    141145    def set_value(self, pin):
    142146        self._model.set_pin(pin)
    143147
     148
    144149class PukEntry(EntryWithLabel):
    145150    def __init__(self, model):
    146151        EntryWithLabel.__init__(self, _('Personal Unblocking Key (PUK):'))
    class ModemConfiguration(SectionView): 
    192197            self._upper_box.show()
    193198
    194199
    195             box = gtk.HBox(spacing=style.DEFAULT_SPACING*2)
     200            box = gtk.HBox(spacing=style.DEFAULT_SPACING * 2)
    196201            label = gtk.Label(_('Country:'))
    197202            label.set_alignment(1, 0.5)
    198203            label_group.add_widget(label)
    class ModemConfiguration(SectionView): 
    211216            self._upper_box.pack_start(box, False)
    212217            box.show()
    213218
    214             box = gtk.HBox(spacing=style.DEFAULT_SPACING*2)
     219            box = gtk.HBox(spacing=style.DEFAULT_SPACING * 2)
    215220            label = gtk.Label(_('Provider:'))
    216221            label.set_alignment(1, 0.5)
    217222            label_group.add_widget(label)
    class ModemConfiguration(SectionView): 
    346351
    347352    def _validate(self):
    348353        if self._username_entry.is_valid and \
    349             self._password_entry.is_valid and \
     354                self._password_entry.is_valid and \
    350355                self._number_entry.is_valid and \
    351                     self._apn_entry.is_valid and \
    352                         self._pin_entry.is_valid and \
    353                             self._puk_entry.is_valid:
    354                                 self.props.is_valid = True
     356                self._apn_entry.is_valid and \
     357                self._pin_entry.is_valid and \
     358                self._puk_entry.is_valid:
     359            self.props.is_valid = True
    355360        else:
    356361            self.props.is_valid = False
    357362
    class ModemConfiguration(SectionView): 
    359364        if entry.is_valid:
    360365            self.needs_restart = True
    361366        self._validate()
    362