Changeset 976 for pykota/trunk/pykota
- Timestamp:
- 04/30/03 15:36:40 (21 years ago)
- Location:
- pykota/trunk/pykota
- Files:
-
- 1 added
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/accounter.py
r973 r976 21 21 # 22 22 # $Log$ 23 # Revision 1.2 2003/04/30 13:36:40 jalet 24 # Stupid accounting method was added. 25 # 23 26 # Revision 1.1 2003/04/29 18:37:54 jalet 24 27 # Pluggable accounting methods (actually doesn't support external scripts) … … 26 29 # 27 30 # 31 32 import sys 28 33 29 34 class PyKotaAccounterError(Exception): … … 42 47 self.filter = kotafilter 43 48 49 def filterInput(self, inputfile) : 50 """Transparent filter.""" 51 mustclose = 0 52 if inputfile is not None : 53 if hasattr(inputfile, "read") : 54 infile = inputfile 55 else : 56 infile = open(inputfile, "rb") 57 mustclose = 1 58 else : 59 infile = sys.stdin 60 data = infile.read(256*1024) 61 while data : 62 sys.stdout.write(data) 63 data = infile.read(256*1024) 64 if mustclose : 65 infile.close() 66 44 67 def doAccounting(self, printerid, userid) : 45 68 """Does the real accounting.""" -
pykota/trunk/pykota/accounters/querying.py
r973 r976 21 21 # 22 22 # $Log$ 23 # Revision 1.2 2003/04/30 13:36:40 jalet 24 # Stupid accounting method was added. 25 # 23 26 # Revision 1.1 2003/04/29 18:37:54 jalet 24 27 # Pluggable accounting methods (actually doesn't support external scripts) … … 27 30 # 28 31 32 import sys 29 33 from pykota.accounter import AccounterBase, PyKotaAccounterError 30 34 from pykota.requester import openRequester, PyKotaRequesterError … … 118 122 119 123 return action 124 -
pykota/trunk/pykota/config.py
r973 r976 21 21 # 22 22 # $Log$ 23 # Revision 1.25 2003/04/30 13:36:40 jalet 24 # Stupid accounting method was added. 25 # 23 26 # Revision 1.24 2003/04/29 18:37:54 jalet 24 27 # Pluggable accounting methods (actually doesn't support external scripts) … … 197 200 for its internal lifetime page counter. 198 201 """ 199 validaccounters = [ "querying" ]202 validaccounters = [ "querying", "stupid" ] 200 203 try : 201 204 accounter = self.getPrinterOption(printer, "accounter").lower() -
pykota/trunk/pykota/storages/postgresql.py
r967 r976 21 21 # 22 22 # $Log$ 23 # Revision 1.10 2003/04/30 13:36:40 jalet 24 # Stupid accounting method was added. 25 # 23 26 # Revision 1.9 2003/04/27 08:04:15 jalet 24 27 # LDAP storage backend's skeleton added. DOESN'T WORK. … … 111 114 def doQuote(self, field) : 112 115 """Quotes a field for use as a string in SQL queries.""" 113 if type(field) == type(0) : # TODO : do something safer116 if type(field) in (type(0), type(0.0)) : # TODO : do something safer 114 117 typ = "decimal" 115 118 else : -
pykota/trunk/pykota/storages/sql.py
r967 r976 21 21 # 22 22 # $Log$ 23 # Revision 1.31 2003/04/30 13:36:40 jalet 24 # Stupid accounting method was added. 25 # 23 26 # Revision 1.30 2003/04/27 08:04:15 jalet 24 27 # LDAP storage backend's skeleton added. DOESN'T WORK. … … 368 371 self.doQuery("UPDATE grouppquota SET datelimit=%s::TIMESTAMP WHERE groupid=%s AND printerid=%s" % (self.doQuote("%04i-%02i-%02i %02i:%02i:%02i" % (datelimit.year, datelimit.month, datelimit.day, datelimit.hour, datelimit.minute, datelimit.second)), self.doQuote(groupid), self.doQuote(printerid))) 369 372 370 def addJobToHistory(self, jobid, userid, printerid, pagecounter, action ) :373 def addJobToHistory(self, jobid, userid, printerid, pagecounter, action, jobsize=None) : 371 374 """Adds a job to the history: (jobid, userid, printerid, last page counter taken from requester).""" 372 self.doQuery("INSERT INTO jobhistory (jobid, userid, printerid, pagecounter, action ) VALUES (%s, %s, %s, %s, %s)" % (self.doQuote(jobid), self.doQuote(userid), self.doQuote(printerid), self.doQuote(pagecounter), self.doQuote(action)))375 self.doQuery("INSERT INTO jobhistory (jobid, userid, printerid, pagecounter, action, jobsize) VALUES (%s, %s, %s, %s, %s, %s)" % (self.doQuote(jobid), self.doQuote(userid), self.doQuote(printerid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize))) 373 376 return self.getJobHistoryId(jobid, userid, printerid) # in case jobid is not sufficient 374 377 … … 379 382 def getPrinterPageCounter(self, printerid) : 380 383 """Returns the last page counter value for a printer given its id, also returns last username, last jobid and history line id.""" 381 result = self.doQuery("SELECT jobhistory.id, jobid, userid, username, pagecounter FROM jobhistory, users WHERE printerid=%s AND userid=users.id ORDER BY jobdate DESC LIMIT 1" % self.doQuote(printerid))384 result = self.doQuery("SELECT jobhistory.id, jobid, userid, username, pagecounter, jobsize FROM jobhistory, users WHERE printerid=%s AND userid=users.id ORDER BY jobdate DESC LIMIT 1" % self.doQuote(printerid)) 382 385 try : 383 386 return self.doParseResult(result)[0] -
pykota/trunk/pykota/version.py
r973 r976 21 21 # 22 22 23 __version__ = "1.05alpha 2-unofficial"23 __version__ = "1.05alpha3-unofficial" 24 24 25 25 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""