diff options
-rw-r--r-- | ChangeLog | 22 | ||||
-rw-r--r-- | iw/network_gui.py | 27 | ||||
-rw-r--r-- | textw/network_text.py | 93 |
3 files changed, 99 insertions, 43 deletions
@@ -1,5 +1,27 @@ 2006-09-29 David Cantrell <dcantrell@redhat.com> + * iw/network_gui.py (NetworkWindow): Removed duplicate handleIPError() + function. Wrap ipv6prefix input validation to catch exception where + the user left the field blank (ValueError). + + * textw/network_text.py: Added descr hash. Removed badIPDisplay(). + + * textw/network_text.py: Added handleIPError() and handleIPMissing() + which work in the same way as the functions of the same name in the + iw interface, but they are modified to use ButtonChoiceWindow. + + * textw/network_text.py (NetworkDeviceWindow): Replace all instances + of self.intf.messageWindow with ButtonChoiceWindow. Call the + handleIPError() and handleIPMissing() functions correctly. Catch + ipv6prefix entry errors when the user left the field blank. + + * textw/network_text.py (NetworkGlobalWindow): Rewrote input + validation for gateway, primary DNS, and secondary DNS. Use + exceptions from network and handleIPError() and handleIPMissing() + functions. + +2006-09-29 David Cantrell <dcantrell@redhat.com> + * textw/network_text.py: Removed badIPDisplay() for now. Removed sanityCheckIPString() because we can just use the one in network. diff --git a/iw/network_gui.py b/iw/network_gui.py index 911272543..10acbcc22 100644 --- a/iw/network_gui.py +++ b/iw/network_gui.py @@ -170,12 +170,6 @@ class NetworkWindow(InstallWindow): self.intf.messageWindow(_("Error With Data"), _("The hostname \"%s\" is not valid for the following reason:\n\n%s") % (hostname, error)) - def handleIPError(self, field, errmsg): - newfield = string.replace(field, "_", "") - self.intf.messageWindow(_("Error With Data"), - _("An error occurred converting " - "the value entered for \"%s\":\n%s") % (newfield, errmsg)) - def handleIPMissing(self, field): try: newfield = descr[field] @@ -396,6 +390,7 @@ class NetworkWindow(InstallWindow): entrys['remip'] = ptplist[1] ipTable.attach(ptplist[1], 1, 2, 3, 4, xpadding=0, ypadding=0) + # Wireless settings if (isys.isWireless(dev)): wifilist.append(gtk.Label(_("_ESSID:"))) wifilist[0].set_alignment(0.0, 0.5) @@ -512,12 +507,20 @@ class NetworkWindow(InstallWindow): break elif t == 'ipv6prefix' and IPV6cb.get_active() is True: - if int(val) > 128 or int(val) < 0: - self.intf.messageWindow(_("Invalid Prefix"), - _("IPv6 prefix must be " - "between 0 and 128.")) - valsgood = 0 - break + try: + if int(val) > 128 or int(val) < 0: + self.intf.messageWindow(_("Invalid Prefix"), + _("IPv6 prefix must be " + "between 0 and 128.")) + valsgood = 0 + break + except: + self.intf.messageWindow(_("Invalid Prefix"), + _("Invalid or missing " + "IPv6 prefix (must be " + "between 0 and 128.")) + valsgood = 0 + break if valsgood == 0: continue diff --git a/textw/network_text.py b/textw/network_text.py index bc56bb97e..a39c53707 100644 --- a/textw/network_text.py +++ b/textw/network_text.py @@ -25,16 +25,30 @@ from constants_text import * from constants import * from rhpl.translate import _ +descr = { 'ipaddr': 'IPv4 address', + 'netmask': 'IPv4 network mask', + 'remip': 'point-to-point IP address', + 'ipv6addr': 'IPv6 address' + } + # order to check input values checkorder = ['ipaddr', 'netmask', 'ipv6addr', 'ipv6prefix', 'remip', 'essid', 'key' ] -#def badIPDisplay(screen, the_ip): -# ButtonChoiceWindow(screen, _("Invalid IP string"), -# _("The entered IP '%s' is not a valid IP.") %(the_ip,), -# buttons = [ _("OK") ]) -# return +def handleIPError(screen, field, msg): + ButtonChoiceWindow(screen, _("Error With %s Data") % (field,), msg, + buttons = [ _("OK") ]) + +def handleIPMissing(screen, field): + try: + newfield = descr[field] + except: + newfield = field + + ButtonChoiceWindow(screen, _("Error With Data"), + _("A value is required for the field \"%s\".") + % (newfield,), buttons = [ _("OK") ]) class NetworkDeviceWindow: def runScreen(self, screen, net, dev, showonboot=1): @@ -320,16 +334,16 @@ class NetworkDeviceWindow: if t == 'netmask' and val.find('.') == -1: try: if int(val) > 32 or int(val) < 0: - self.intf.messageWindow(_("Invalid Prefix"), - _("IPv4 prefix " - "must be between" - "0 and 32.")) + ButtonChoiceWindow(screen, + _("Invalid Prefix"), + _("IPv4 prefix must be between " + "0 and 32."), buttons = [_("OK")]) valsgood = 0 break else: val = isys.inet_convertPrefixToNetmask(val) except: - self.handleIPMissing(t) + handleIPMissing(screen, t) valsgood = 0 break @@ -337,19 +351,26 @@ class NetworkDeviceWindow: network.sanityCheckIPString(val) tmpvals[t] = val except network.IPMissing, msg: - self.handleIPMissing(t) + handleIPMissing(screen, t) valsgood = 0 break except network.IPError, msg: - self.handleIPError(t, msg) + handleIPError(screen, t, msg) valsgood = 0 break elif t == 'ipv6prefix' and self.ipv6Cb.selected(): - if int(val) > 128 or int(val) < 0: - self.intf.messageWindow(_("Invalid Prefix"), - _("IPv6 prefix must be " - "between 0 and 128.")) + try: + if int(val) > 128 or int(val) < 0: + ButtonChoiceWindow(screen, _("Invalid Prefix"), + _("IPv6 prefix must be between 0 and 128."), + buttons = [_("OK")]) + valsgood = 0 + break + except: + ButtonChoiceWindow(screen, _("Invalid Prefix"), + _("Invalid or missing IPv6 prefix (must be " + "between 0 and 128."), buttons = [_("OK")]) valsgood = 0 break @@ -466,26 +487,36 @@ class NetworkGlobalWindow: screen.popWindow() return INSTALL_BACK - val = gwEntry.value() - if val and network.sanityCheckIPString(val) is not None: - screen.suspend() - print "gw", val, network.sanityCheckIPString(val) - screen.resume() - #badIPDisplay(screen, val) + try: + network.sanityCheckIPString(gwEntry.value()) + anaconda.id.network.gateway = gwEntry.value() + except network.IPMissing, msg: + handleIPMissing(screen, 'gateway') + continue + except network.IPError, msg: + handleIPError(screen, 'gateway', msg) continue - anaconda.id.network.gateway = val - val = ns1Entry.value() - if val and network.sanityCheckIPString(val) is not None: - #badIPDisplay(screen, val) + try: + network.sanityCheckIPString(ns1Entry.value()) + anaconda.id.network.primaryNS = ns1Entry.value() + except network.IPMissing, msg: + handleIPMissing(screen, 'primary DNS') + continue + except network.IPError, msg: + handleIPError(screen, 'primary DNS', msg) continue - anaconda.id.network.primaryNS = val - val = ns2Entry.value() - if val and network.sanityCheckIPString(val) is not None: - #badIPDisplay(screen, val) + try: + network.sanityCheckIPString(ns2Entry.value()) + anaconda.id.network.secondaryNS = ns2Entry.value() + except network.IPMissing, msg: + handleIPMissing(screen, 'secondary DNS') continue - anaconda.id.network.secondaryNS = val + except network.IPError, msg: + handleIPError(screen, 'secondary DNS', msg) + continue + break screen.popWindow() |