Changeset 1041 for pykota/trunk/pykota/accounters/external.py
- Timestamp:
- 06/25/03 16:10:01 (21 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/accounters/external.py
r1000 r1041 21 21 # 22 22 # $Log$ 23 # Revision 1.4 2003/06/25 14:10:01 jalet 24 # Hey, it may work (edpykota --reset excepted) ! 25 # 23 26 # Revision 1.3 2003/05/27 23:00:21 jalet 24 27 # Big rewrite of external accounting methods. … … 41 44 42 45 class Accounter(AccounterBase) : 43 def doAccounting(self, printer id, userid) :46 def doAccounting(self, printer, user) : 44 47 """Deletgates the computation of the job size to an external command. 45 48 … … 50 53 51 54 # get last job information for this printer 52 pgc = self.filter.storage.getPrinterPageCounter(printerid) 53 if pgc is None : 55 if not printer.LastJob.Exists : 54 56 # The printer hasn't been used yet, from PyKota's point of view 55 57 counterbeforejob = 0 … … 58 60 # Last lifetime page counter before actual job is 59 61 # last page counter + last job size 60 counterbeforejob = (pgc["pagecounter"] or 0) + (pgc["jobsize"]or 0)62 counterbeforejob = int(printer.LastJob.PrinterPageCounter or 0) + int(printer.LastJob.JobSize or 0) 61 63 62 64 # Is the current user allowed to print at all ? 63 action = self.filter.warnUserPQuota(self.filter.username, self.filter.printername) 65 userpquota = self.filter.storage.getUserPQuota(user, printer) 66 action = self.filter.warnUserPQuota(userpquota) 64 67 65 68 # update the quota for the current user on this printer, if allowed to print … … 67 70 jobsize = 0 68 71 else : 69 self.filter.storage.updateUserPQuota(userid, printerid,jobsize)72 userpquota.increasePagesUsage(jobsize) 70 73 71 74 # adds the current job to history 72 self.filter.storage.addJobToHistory(self.filter.jobid, self.filter.storage.getUserId(self.filter.username), printerid, counterbeforejob, action, jobsize)75 printer.addJobToHistory(self.filter.jobid, user, counterbeforejob, action, jobsize) 73 76 74 77 return action … … 102 105 # launches child process 103 106 command = "%s <%s >%s 2>%s" % (self.arguments, infilename, outfilename, errfilename) 104 o = open("/tmp/comm", "w")105 o.write("%s\n" % command)106 o.close()107 107 retcode = os.system(command) 108 108