Changeset 1624 for pykota/trunk/bin
- Timestamp:
- 07/23/04 00:41:48 (20 years ago)
- Location:
- pykota/trunk/bin
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r1606 r1624 24 24 # 25 25 # $Log$ 26 # Revision 1.69 2004/07/22 22:41:47 jalet 27 # Hardware accounting for LPRng should be OK now. UNTESTED. 28 # 26 29 # Revision 1.68 2004/07/20 22:19:44 jalet 27 30 # Sanitized a bit + use of gettext … … 400 403 401 404 self.printInfo(_("Job accounting begins.")) 402 self.accounter.beginJob( userpquota)405 self.accounter.beginJob(printer) 403 406 else : 404 407 action = "ALLOW" … … 419 422 420 423 # stops accounting. 421 self.accounter.endJob( userpquota)424 self.accounter.endJob(printer) 422 425 self.printInfo(_("Job accounting ends.")) 423 426 -
pykota/trunk/bin/lprngpykota
r1611 r1624 24 24 # 25 25 # $Log$ 26 # Revision 1.4 2004/07/22 22:41:48 jalet 27 # Hardware accounting for LPRng should be OK now. UNTESTED. 28 # 26 29 # Revision 1.3 2004/07/21 09:35:48 jalet 27 30 # Software accounting seems to be OK with LPRng support now … … 84 87 # and that the second pass didn't work or wasn't even launched 85 88 # we know have to act just as if we were in second pass 86 raise PyKotaToolError, "Not implemented yet !" 89 # for previous user on this printer, then we will continue 90 # with normal processing of current user. 91 self.secondPass(policy, printer, None, None) 92 93 # export user info with initial values 94 self.exportUserInfo(userpquota) 87 95 88 96 # tries to extract job-originating-hostname … … 119 127 120 128 self.logdebug("Job accounting begins.") 121 self.accounter.beginJob( userpquota)129 self.accounter.beginJob(printer) 122 130 123 131 jobsize = None 124 132 if self.accounter.isSoftware : 125 self.accounter.endJob( userpquota)133 self.accounter.endJob(printer) 126 134 jobsize = self.accounter.getJobSize() 127 135 self.logdebug("Job accounting ends.") … … 131 139 self.logdebug("Job size forced to 0 because printing was denied.") 132 140 133 if jobsize is not None :141 if self.accounter.isSoftware : 134 142 # update the quota for the current user on this printer 135 143 self.logdebug("Job size : %i" % jobsize) … … 180 188 raise PyKotaToolError, _("Hardware accounting already finished ! This should be impossible, please report this problem ASAP.") 181 189 190 # here if user and userpquota are both None 191 # then it's a special second pass for a job 192 # which should have had one but didn't, so 193 # we need to get the last user, not the current one. 194 if (user is None) and (userpquota is None) : 195 user = printer.LastJob.User 196 userpquota = self.storage.getUserPQuota(user, printer) 197 198 # exports user info for last user 199 self.exportUserInfo(userpquota) 200 182 201 # indicate phase change 183 202 os.environ["PYKOTAPHASE"] = "AFTER" 184 203 204 # fakes beginning of job with old page counter 205 self.accounter.LastPageCounter = int(printer.LastJob.PrinterPageCounter or 0) 206 self.accounter.fakeBeginJob() 207 self.logdebug("Fakes beginning of job with LastPageCounter: %s" % self.accounter.getLastPageCounter()) 208 185 209 # stops accounting. 186 self.accounter.endJob( userpquota)210 self.accounter.endJob(printer) 187 211 self.logdebug("Job accounting ends.") 188 212 189 213 # retrieve the job size 190 214 jobsize = self.accounter.getJobSize() 215 191 216 self.logdebug("Job size : %i" % jobsize) 192 raise PyKotaToolError, "Not implemented !" 217 self.logdebug("Updating user %s's quota on printer %s" % (user.Name, printer.Name)) 218 jobprice = userpquota.increasePagesUsage(jobsize) 219 220 self.storage.writeLastJobSize(printer.LastJob, jobsize, jobprice) 221 self.logdebug("Job size and price now set in history.") 222 223 # exports some new environment variables 224 os.environ["PYKOTAPHASE"] = "AFTER" 225 os.environ["PYKOTAJOBSIZE"] = str(jobsize) 226 os.environ["PYKOTAJOBPRICE"] = str(jobprice) 227 228 # then re-export user information with new value 229 self.exportUserInfo(userpquota) 230 231 # Launches the post hook 232 self.posthook(userpquota) 233 234 # here hardware accounting was completed. 193 235 return self.acceptJob() 194 236 … … 204 246 return self.acceptJob() 205 247 else : 206 # exports user information with initial values207 self.exportUserInfo(userpquota)208 209 248 if (not printer.LastJob.Exists) or (printer.LastJob.JobId != self.jobid) : 210 249 # Last job for current printer has a different JobId than