Changeset 750 for pykota/trunk/bin
- Timestamp:
- 02/07/03 23:53:57 (22 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/edpykota
r749 r750 17 17 # 18 18 # $Log$ 19 # Revision 1.8 2003/02/07 22:53:57 jalet 20 # Checks if printer name is valid before adding it 21 # 19 22 # Revision 1.7 2003/02/07 22:17:58 jalet 20 23 # Incomplete test … … 122 125 class EdPyKota(PyKotaTool) : 123 126 """A class for edpykota.""" 127 def isValidPrinterName(self, printername) : 128 """Checks if a printername is valid.""" 129 import string 130 if printername[0] in string.ascii_letters : 131 validchars = string.ascii_letters + string.digits + "-_" 132 for c in printername[1:] : 133 if c not in validchars : 134 return 0 135 return 1 136 return 0 137 124 138 def main(self, names, options) : 125 139 """Edit user or group quotas.""" 126 140 printernames = self.storage.getMatchingPrinters(options["printer"]) 127 141 if not printernames : 128 if options["add"] and options["printer"] and options["printer"].isalpha() : 129 self.storage.addPrinter(options["printer"]) 142 pname = options["printer"] 143 if options["add"] and pname : 144 if self.isValidPrinterName(pname) : 145 self.storage.addPrinter(pname) 146 else : 147 raise PyKotaToolError, "Invalid printer name %s" % pname 130 148 else : 131 raise PyKotaToolError, "There's no printer matching %s" % options["printer"]149 raise PyKotaToolError, "There's no printer matching %s" % pname 132 150 softlimit = hardlimit = None 133 151 if options["softlimit"] :