Changeset 740
- Timestamp:
- 02/07/03 11:23:48 (22 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pykota
r728 r740 17 17 # 18 18 # $Log$ 19 # Revision 1.7 2003/02/07 10:23:48 jalet 20 # Avoid a possible future name clash 21 # 19 22 # Revision 1.6 2003/02/06 22:54:33 jalet 20 23 # warnpykota should be ok … … 99 102 100 103 # Initializes the current tool 101 tool= PyKotaFilter(username)104 kotafilter = PyKotaFilter(username) 102 105 103 106 # Get the page counter directly from the printer itself 104 counterbeforejob = tool.requester.getPrinterPageCounter(tool.printerhostname) # TODO use printername instead, make them match from CUPS' config files107 counterbeforejob = kotafilter.requester.getPrinterPageCounter(kotafilter.printerhostname) # TODO use printername instead, make them match from CUPS' config files 105 108 106 109 # Get the last page counter and last username from the Quota Storage backend 107 pgc = tool.storage.getPrinterPageCounter(tool.printername)110 pgc = kotafilter.storage.getPrinterPageCounter(kotafilter.printername) 108 111 if pgc is None : 109 112 # The printer is unknown from the Quota Storage perspective 110 113 # we let the job pass through, but log a warning message 111 tool.logger.log_message("Printer %s not registered in the PyKota system" % tool.printername, "warn")114 kotafilter.logger.log_message("Printer %s not registered in the PyKota system" % kotafilter.printername, "warn") 112 115 else : 113 116 (lastpagecounter, lastusername) = (pgc["pagecounter"], pgc["lastusername"]) … … 115 118 # Update the last page counter and last username in the Quota Storage backend 116 119 # set them to current user and 117 tool.storage.updatePrinterPageCounter(tool.printername, username, counterbeforejob) # TODO : allow or deny users not in quota system, and die cleanly if needed120 kotafilter.storage.updatePrinterPageCounter(kotafilter.printername, username, counterbeforejob) # TODO : allow or deny users not in quota system, and die cleanly if needed 118 121 119 122 # Is the current user allowed to print at all ? 120 action = tool.warnUserPQuota(username)123 action = kotafilter.warnUserPQuota(username) 121 124 if action == "DENY" : 122 125 # No, just die cleanly … … 129 132 jobsize = (counterbeforejob - lastpagecounter) 130 133 if jobsize >= 0: 131 tool.storage.updateUserPQuota(lastusername, tool.printername, jobsize)132 tool.warnUserPQuota(lastusername)134 kotafilter.storage.updateUserPQuota(lastusername, kotafilter.printername, jobsize) 135 kotafilter.warnUserPQuota(lastusername) 133 136 else : 134 tool.logger.log_message("Error in page count value %i for user %s on printer %s" % (jobsize, tool.printername, lastusername), "error")137 kotafilter.logger.log_message("Error in page count value %i for user %s on printer %s" % (jobsize, kotafilter.printername, lastusername), "error") 135 138 136 139 # pass the job untouched to the underlying layer 137 tool.filterInput(inputfile)140 kotafilter.filterInput(inputfile) 138 141 139 142 return 0