Changeset 3549 for pykota/trunk/bin
- Timestamp:
- 08/18/10 04:20:57 (14 years ago)
- Location:
- pykota/trunk/bin
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r3545 r3549 557 557 setenv("PYKOTALIFETIMEPAID", str(self.User.LifeTimePaid or 0.0), self.charset) 558 558 setenv("PYKOTAUSERDESCRIPTION", self.User.Description or "", self.charset) 559 setenv("PYKOTAMAXJOBSIZE", ((self.UserPQuota.MaxJobSize is None) and _("Unlimited")) or str(self.UserPQuota.MaxJobSize), self.charset) 559 560 560 561 setenv("PYKOTAPAGECOUNTER", str(self.UserPQuota.PageCounter or 0), self.charset) … … 1027 1028 # This printer was set to refuse jobs this large. 1028 1029 self.printInfo(_("Precomputed job size (%s pages) too large for printer %s.") % (self.softwareJobSize, self.PrinterName), "warn") 1030 self.Action = "DENY" 1031 # here we don't put the precomputed job size in the message 1032 # because in case of error the user could complain :-) 1033 self.Reason = _("You are not allowed to print so many pages on printer %s at this time.") % self.PrinterName 1034 1035 if self.Action not in ("DENY", "CANCEL") : 1036 if (self.UserPQuota.MaxJobSize is not None) and (self.softwareJobSize > self.UserPQuota.MaxJobSize) : 1037 # This user print quota entry was set to refuse jobs this large. 1038 self.printInfo(_("Precomputed job size (%s pages) too large for user %s on printer %s.") % (self.softwareJobSize, self.UserName, self.PrinterName), "warn") 1029 1039 self.Action = "DENY" 1030 1040 # here we don't put the precomputed job size in the message -
pykota/trunk/bin/edpykota
r3489 r3549 36 36 class EdPyKota(PyKotaTool) : 37 37 """A class for edpykota.""" 38 def modifyPQEntry(self, pqkey, pqentry, noquota, softlimit, hardlimit, increase, reset, hardreset, suffix, used ) :38 def modifyPQEntry(self, pqkey, pqentry, noquota, softlimit, hardlimit, increase, reset, hardreset, suffix, used, maxjobsize) : 39 39 """Modifies a print quota entry.""" 40 40 if noquota or ((softlimit is not None) and (hardlimit is not None)) : … … 54 54 if used : 55 55 pqentry.setUsage(used) 56 if maxjobsize is not None : 57 if maxjobsize == "unlimited" : 58 pqentry.setMaxJobSize(None) 59 else : 60 pqentry.setMaxJobSize(maxjobsize) 56 61 57 62 def main(self, names, options) : … … 77 82 or options.noquota \ 78 83 or options.increase \ 84 or options.maxjobsize \ 79 85 or options.skipexisting))) \ 80 86 or (options.groups and (options.used \ 87 or options.maxjobsize \ 81 88 or options.increase \ 82 89 or options.reset \ … … 106 113 self.display(" %s\n" % (_("Hard limit : %s") % pqentry.HardLimit)) 107 114 self.display(" %s\n" % (_("Date limit : %s") % pqentry.DateLimit)) 108 self.display(" %s (Not supported yet)\n" % (_("Maximum job size : %s") % ((pqentry.MaxJobSize and (_("%s pages") % pqentry.MaxJobSize)) or _("Unlimited")))) 115 if suffix == "User" : 116 self.display(" %s\n" % (_("Maximum job size : %s") % (((pqentry.MaxJobSize is not None) and (_("%s pages") % pqentry.MaxJobSize)) or _("Unlimited")))) 109 117 if hasattr(pqentry, "WarnCount") : 110 118 self.display(" %s\n" % (_("Warning banners printed : %s") % pqentry.WarnCount)) … … 159 167 self.printInfo(_("Undefined soft limit set to hard limit (%s).") % str(softlimit)) 160 168 169 if options.maxjobsize : 170 if options.maxjobsize.lower() == "unlimited" : 171 maxjobsize = "unlimited" 172 else : 173 try : 174 maxjobsize = int(options.maxjobsize) 175 if maxjobsize < 0 : 176 raise ValueError 177 except ValueError : 178 raise PyKotaCommandLineError, _("Invalid maximum job size value %s") % options.maxjobsize 179 else : 180 maxjobsize = None 181 161 182 self.storage.beginTransaction() 162 183 try : … … 183 204 options.hardreset, 184 205 suffix, 185 used) 206 used, 207 maxjobsize) 186 208 oldpqentry = getattr(self.storage, "add%sPQuota" % suffix)(pqentry) 187 209 if oldpqentry is not None : … … 201 223 options.hardreset, 202 224 suffix, 203 used) 225 used, 226 maxjobsize) 204 227 oldpqentry.save() 205 228 percent.oneMore() … … 220 243 options.hardreset, 221 244 suffix, 222 used) 245 used, 246 maxjobsize) 223 247 pqentry.save() 224 248 percent.oneMore() … … 263 287 dest="action", 264 288 help=_("Display detailed informations about the specified users or groups print quota entries.")) 289 parser.add_option("-m", "--maxjobsize", 290 dest="maxjobsize", 291 help=_("Set the maximum job size in pages the specified users are allowed to print to the specified printers in a single job. Accepted values are '0' to forbid printing, 'unlimited' to allow unrestricted printing, or any positive integer value. This option is not supported for users groups.")) 265 292 parser.add_option("-n", "--noquota", 266 293 dest="noquota", -
pykota/trunk/bin/pkprinters
r3489 r3549 50 50 printer.setPassThrough(True) 51 51 if maxjobsize is not None : 52 printer.setMaxJobSize(maxjobsize) 52 if maxjobsize == "unlimited" : 53 printer.setMaxJobSize(None) 54 else : 55 printer.setMaxJobSize(maxjobsize) 53 56 54 57 def managePrintersGroups(self, pgroups, printer, remove) : … … 151 154 (_("Passthrough mode : %s") % ((printer.PassThrough and _("ON")) or _("OFF")))) 152 155 self.display(" %s\n" % \ 153 (_("Maximum job size : %s") % (( printer.MaxJobSizeand (_("%s pages") % printer.MaxJobSize)) or _("Unlimited"))))156 (_("Maximum job size : %s") % (((printer.MaxJobSize is not None) and (_("%s pages") % printer.MaxJobSize)) or _("Unlimited")))) 154 157 self.display(" %s\n" % (_("Routed through PyKota : %s") % ((self.isPrinterCaptured(printer.Name) and _("YES")) or _("NO")))) 155 158 if parents : … … 188 191 189 192 if options.maxjobsize : 190 try : 191 maxjobsize = int(options.maxjobsize) 192 if maxjobsize < 0 : 193 raise ValueError 194 except ValueError : 195 raise PyKotaCommandLineError, _("Invalid maximum job size value %s") % options.maxjobsize 193 if options.maxjobsize.lower() == "unlimited" : 194 maxjobsize = "unlimited" 195 else : 196 try : 197 maxjobsize = int(options.maxjobsize) 198 if maxjobsize < 0 : 199 raise ValueError 200 except ValueError : 201 raise PyKotaCommandLineError, _("Invalid maximum job size value %s") % options.maxjobsize 196 202 else : 197 203 maxjobsize = None … … 306 312 parser.add_option("-m", "--maxjobsize", 307 313 dest="maxjobsize", 308 help=_("Set the maximum job size in pages allowed on the specified printers. "))314 help=_("Set the maximum job size in pages allowed on the specified printers. Accepted values are '0' to forbid printing, 'unlimited' to allow unrestricted printing, or any positive integer value.")) 309 315 parser.add_option("-n", "--nopassthrough", 310 316 action="store_true", -
pykota/trunk/bin/pykotme
r3489 r3549 92 92 userpquota = self.storage.getUserPQuota(user, printer) 93 93 if userpquota.Exists : 94 if printer.MaxJobSize and (totalsize > printer.MaxJobSize) : 94 if (printer.MaxJobSize and (totalsize > printer.MaxJobSize)) \ 95 or (userpquota.MaxJobSize and (totalsize > userpquota.MaxJobSize)) : 95 96 self.display("%s\n" % (_("User %(username)s is not allowed to print so many pages on printer %(printername)s at this time.") % locals())) 96 97 else :