| 95 | sizeprinted = False |
| 96 | done = {} |
| 97 | for printer in printers : |
| 98 | # Now fake some values. TODO : improve API to not need this anymore |
| 99 | self.PrinterName = printer.Name |
| 100 | self.JobSizeBytes = 1 |
| 101 | self.preaccounter = openAccounter(self, ispreaccounter=1) |
| 102 | key = self.preaccounter.name + self.preaccounter.arguments |
| 103 | if not done.has_key(key) : |
| 104 | totalsize = 0 |
| 105 | inkusage = [] |
| 106 | for filename in files : |
| 107 | self.DataFile = filename |
| 108 | self.preaccounter.beginJob(None) |
| 109 | self.preaccounter.endJob(None) |
| 110 | totalsize += self.preaccounter.getJobSize(None) |
| 111 | inkusage.extend(self.preaccounter.inkUsage) |
| 112 | done[key] = (totalsize, inkusage) |
| 113 | (totalsize, inkusage) = done[key] |
| 114 | if not sizeprinted : |
| 115 | print _("Job size : %i pages") % totalsize |
| 116 | sizeprinted = True |
| 117 | userpquota = self.storage.getUserPQuota(user, printer) |
| 118 | if userpquota.Exists : |
| 119 | if printer.MaxJobSize and (totalsize > printer.MaxJobSize) : |
| 120 | print _("You are not allowed to print so many pages on printer %s at this time.") % printer.Name |
| 121 | else : |
| 122 | cost = userpquota.computeJobPrice(totalsize, inkusage) |
| 123 | msg = _("Cost on printer %s : %.2f") % (printer.Name, cost) |
| 124 | if printer.PassThrough : |
| 125 | msg = "%s (%s)" % (msg, _("won't be charged, printer is in passthrough mode")) |
| 126 | elif user.LimitBy == "nochange" : |
| 127 | msg = "%s (%s)" % (msg, _("won't be charged, your account is immutable")) |
| 128 | print msg |
106 | | else : |
107 | | for printer in printers : |
108 | | userpquota = self.storage.getUserPQuota(user, printer) |
109 | | if userpquota.Exists : |
110 | | if printer.MaxJobSize and (totalsize > printer.MaxJobSize) : |
111 | | print _("You are not allowed to print so many pages on printer %s at this time.") % printer.Name |
112 | | else : |
113 | | cost = userpquota.computeJobPrice(totalsize) |
114 | | msg = _("Cost on printer %s : %.2f") % (printer.Name, cost) |
115 | | if printer.PassThrough : |
116 | | msg = "%s (%s)" % (msg, _("won't be charged, printer is in passthrough mode")) |
117 | | elif user.LimitBy == "nochange" : |
118 | | msg = "%s (%s)" % (msg, _("won't be charged, your account is immutable")) |
119 | | print msg |