summaryrefslogtreecommitdiffstats
path: root/network.py
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2006-06-07 17:51:06 +0000
committerChris Lumens <clumens@redhat.com>2006-06-07 17:51:06 +0000
commit6bc5cb7cc41dca020f92af46a2920a04963f0379 (patch)
treead279099d2769f18a067683aa811b4dd22fae789 /network.py
parent3fdc96e374e869699a5f3946c673c893a2657c93 (diff)
downloadanaconda-6bc5cb7cc41dca020f92af46a2920a04963f0379.tar.gz
anaconda-6bc5cb7cc41dca020f92af46a2920a04963f0379.tar.xz
anaconda-6bc5cb7cc41dca020f92af46a2920a04963f0379.zip
Move from IPEditors to gtk.Entrys. This will help when people can enter
IPv6 addresses so we don't have a thousand little boxes on the screen.
Diffstat (limited to 'network.py')
-rw-r--r--network.py28
1 files changed, 12 insertions, 16 deletions
diff --git a/network.py b/network.py
index 755d0dd17..c386e6b9a 100644
--- a/network.py
+++ b/network.py
@@ -32,6 +32,12 @@ from rhpl.simpleconfig import SimpleConfigFile
import logging
log = logging.getLogger("anaconda")
+class IPError(Exception):
+ pass
+
+class IPMissing(Exception):
+ pass
+
def inStrRange(v, s):
if string.find(s, v) == -1:
return 0
@@ -78,25 +84,15 @@ def anyUsingDHCP(devices):
return 1
return 0
-# sanity check an IP string. if valid, returns octets, if invalid, return None
+# sanity check an IP string.
def sanityCheckIPString(ip_string):
ip_re = re.compile('^([0-2]?[0-9]?[0-9])\\.([0-2]?[0-9]?[0-9])\\.([0-2]?[0-9]?[0-9])\\.([0-2]?[0-9]?[0-9])$')
-
- #Sanity check the string
- m = ip_re.match (ip_string)
- try:
- if not m:
- return None
- octets = m.groups()
- if len(octets) != 4:
- return None
- for octet in octets:
- if (int(octet) < 0) or (int(octet) > 255):
- return None
- except TypeError:
- return None
- return octets
+ if ip_string.strip() == "":
+ raise IPMissing, _("IP Address is missing.")
+
+ if not ip_re.match(ip_string):
+ raise IPError, _("IP Addresses must contain four numbers between 0 and 255, separated by periods.")
def hasActiveNetDev():
# try to load /tmp/netinfo and see if we can sniff out network info