diff options
author | Jeremy Katz <katzj@redhat.com> | 2001-08-06 23:09:09 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2001-08-06 23:09:09 +0000 |
commit | d81e7826371b3d9be532fbe5252645f742180d9b (patch) | |
tree | 3b3bb95986aa672220bc52c17abce3a68891b03c /textw | |
parent | f4155f46798f4982ea86c43a26008700b590b1d2 (diff) | |
download | anaconda-d81e7826371b3d9be532fbe5252645f742180d9b.tar.gz anaconda-d81e7826371b3d9be532fbe5252645f742180d9b.tar.xz anaconda-d81e7826371b3d9be532fbe5252645f742180d9b.zip |
do some sanity checking on text inputs which should be integers (50998, 51006)
Diffstat (limited to 'textw')
-rw-r--r-- | textw/partition_text.py | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/textw/partition_text.py b/textw/partition_text.py index a57539a04..f3e7a52f0 100644 --- a/textw/partition_text.py +++ b/textw/partition_text.py @@ -27,6 +27,20 @@ from constants_text import * from translate import _ from log import log + +# sanity checking for various numeric input boxes +def invalidInteger(str): + ints = range(0,10) + if str == "": + return _("Must specify a value") + for n in str: + if n not in ints: + return _("Requested value is not an integer") + if len(str) > 9: + return _("Requested value is too large") + + return None + class PartitionWindow: def populate(self): # XXX we really should separate this stuff out into interface @@ -670,10 +684,9 @@ class PartitionWindow: request.badblocks = badblocksCB.selected() if origrequest.start == None: - if size.value() == "": - self.intf.messageWindow(_("Must Specify Size"), - _("Must specify a base size " - "for the partition.")) + if invalidInteger(size.value()): + self.intf.messageWindow(_("Invalid Entry for Partition Size"), + invalidInteger(size.value())) continue request.size = int(size.value()) @@ -683,10 +696,9 @@ class PartitionWindow: else: grow = TRUE if growtype == "limit": - if limitentry.value() == "": - self.intf.messageWindow(_("Specify Maximum Size"), - _("Please specify a maximum " - "size for the partition.")) + if invalidInteger(limitentry.value()): + self.intf.messageWindow(_("Invalid Entry for Maximum Size"), + invalidInteger(limitentry.value())) continue maxsize = int(limitentry.value()) @@ -703,31 +715,27 @@ class PartitionWindow: allowdrives.append(i) request.drive = allowdrives else: - if start.value() == "": - self.intf.messageWindow(_("Specify Start"), - _("Please specify a starting " - "cylinder for the " - "partition.")) + if invalidInteger(start.value()): + self.intf.messageWindow(_("Invalid Entry for Starting Cylinder"), + invalidInteger(start.value())) continue + request.start = int(start.value()) request.badblocks = badblocksCB.selected() cyltype = cylopts.getSelection() if cyltype == "end": - if end.value() == "": - self.intf.messageWindow(_("Specify End"), - _("Please specify the end " - "cylinder for the " - "partition.")) + if invalidInteger(end.value()): + self.intf.messageWindow(_("Invalid Entry for End Cylinder"), + invalidInteger(end.value())) continue + request.end = int(end.value()) request.size = None elif cyltype == "size": - if size.value() == "": - self.intf.messageWindow(_("Specify Size"), - _("Please specify the " - "size for the " - "partition.")) + if invalidInteger(size.value()): + self.intf.messageWindow(_("Invalid Entry for Partition Size"), + invalidInteger(size.value())) continue request.end = None request.size = int(size.value()) @@ -856,6 +864,11 @@ class PartitionWindow: raidmembers.append(id) request.raidmembers = raidmembers + if invalidInteger(spares.value()): + self.intf.messageWindow(_("Invalid Entry for Raid Spares"), + invalidInteger(spares.value())) + continue + request.raidspares = int(spares.value()) request.raidlevel = raidtype.current() |