Changeset 1180 for pykota/trunk/pykota/accounters/external.py
- Timestamp:
- 11/13/03 00:29:24 (21 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/accounters/external.py
r1144 r1180 22 22 # 23 23 # $Log$ 24 # Revision 1.8 2003/11/12 23:29:24 jalet 25 # More work on new backend. This commit may be unstable. 26 # 24 27 # Revision 1.7 2003/10/07 09:07:28 jalet 25 28 # Character encoding added to please latest version of Python … … 54 57 55 58 class Accounter(AccounterBase) : 59 def beginJob(self, printer, user) : 60 """Saves the computed job size.""" 61 # computes job's size 62 self.JobSize = self.computeJobSize() 63 64 # get last job information for this printer 65 if not printer.LastJob.Exists : 66 # The printer hasn't been used yet, from PyKota's point of view 67 self.LastPageCounter = 0 68 else : 69 # get last job size and page counter from Quota Storage 70 # Last lifetime page counter before actual job is 71 # last page counter + last job size 72 self.LastPageCounter = int(printer.LastJob.PrinterPageCounter or 0) + int(printer.LastJob.JobSize or 0) 73 74 def endJob(self, printer, user) : 75 """Do nothing.""" 76 pass 77 78 def getJobSize(self) : 79 """Returns the actual job size.""" 80 try : 81 return self.JobSize 82 except AttributeError : 83 return 0 84 56 85 def doAccounting(self, printer, user) : 57 86 """Deletgates the computation of the job size to an external command. … … 59 88 The command must print the job size on its standard output and exit successfully. 60 89 """ 90 self.beginJob(printer, user) 91 61 92 # get the job size, which is real job size * number of copies. 62 93 jobsize = self.getJobSize() * self.filter.copies 63 64 # get last job information for this printer65 if not printer.LastJob.Exists :66 # The printer hasn't been used yet, from PyKota's point of view67 counterbeforejob = 068 else :69 # get last job size and page counter from Quota Storage70 # Last lifetime page counter before actual job is71 # last page counter + last job size72 counterbeforejob = int(printer.LastJob.PrinterPageCounter or 0) + int(printer.LastJob.JobSize or 0)73 94 74 95 # Is the current user allowed to print at all ? … … 83 104 84 105 # adds the current job to history 85 printer.addJobToHistory(self.filter.jobid, user, counterbeforejob, action, jobsize) 106 printer.addJobToHistory(self.filter.jobid, user, self.getLastPageCounter(), action, jobsize) 107 108 self.endJob(printer, user) 86 109 87 110 return action 88 111 89 def getJobSize(self) :112 def computeJobSize(self) : 90 113 """Feeds an external command with our datas to let it compute the job size, and return its value.""" 91 114 temporary = None