Changeset 1113 for pykota/trunk/bin
- Timestamp:
- 07/29/03 22:55:17 (21 years ago)
- Location:
- pykota/trunk/bin
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/edpykota
r1105 r1113 23 23 # 24 24 # $Log$ 25 # Revision 1.56 2003/07/29 20:55:17 jalet 26 # 1.14 is out ! 27 # 25 28 # Revision 1.55 2003/07/28 09:11:12 jalet 26 29 # PyKota now tries to add its attributes intelligently in existing LDAP … … 538 541 539 542 if __name__ == "__main__" : 543 retcode = 0 540 544 try : 541 545 defaults = { \ … … 584 588 raise PyKotaToolError, _("incompatible options, see help.") 585 589 else : 586 sys.exit(editor.main(args, options))590 retcode = editor.main(args, options) 587 591 except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError), msg : 588 592 sys.stderr.write("%s\n" % msg) 589 593 sys.stderr.flush() 590 sys.exit(-1) 591 594 retcode = -1 595 596 try : 597 editor.storage.close() 598 except (TypeError, NameError, AttributeError) : 599 pass 600 601 sys.exit(retcode) -
pykota/trunk/bin/pykota
r1080 r1113 23 23 # 24 24 # $Log$ 25 # Revision 1.37 2003/07/29 20:55:17 jalet 26 # 1.14 is out ! 27 # 25 28 # Revision 1.36 2003/07/10 06:09:52 jalet 26 29 # Incorrect documentation string … … 232 235 return -1 233 236 234 def main( ) :237 def main(thefilter) : 235 238 """Do it, and do it right !""" 236 # Initializes the current tool237 kotafilter = PyKotaFilter()238 239 239 # 240 240 # If this is a CUPS filter, we should act and die like a CUPS filter when needed 241 if kotafilter.printingsystem == "CUPS" :241 if thefilter.printingsystem == "CUPS" : 242 242 if len(sys.argv) not in (6, 7) : 243 243 sys.stderr.write("ERROR: %s job-id user title copies options [file]\n" % sys.argv[0]) 244 return kotafilter.removeJob()244 return thefilter.removeJob() 245 245 246 246 # Get the last page counter and last username from the Quota Storage backend 247 printer = kotafilter.storage.getPrinter(kotafilter.printername)247 printer = thefilter.storage.getPrinter(thefilter.printername) 248 248 if not printer.Exists : 249 249 # The printer is unknown from the Quota Storage perspective 250 250 # we let the job pass through, but log a warning message 251 kotafilter.logger.log_message(_("Printer %s not registered in the PyKota system") % kotafilter.printername, "warn")251 thefilter.logger.log_message(_("Printer %s not registered in the PyKota system") % thefilter.printername, "warn") 252 252 else : 253 user = kotafilter.storage.getUser(kotafilter.username)253 user = thefilter.storage.getUser(thefilter.username) 254 254 if not user.Exists : 255 255 # The user is unknown from the Quota Storage perspective … … 257 257 # either let the job pass through or reject it, but we 258 258 # log a message in any case. 259 policy = kotafilter.config.getPrinterPolicy(kotafilter.printername)259 policy = thefilter.config.getPrinterPolicy(thefilter.printername) 260 260 if policy == "ALLOW" : 261 261 action = "POLICY_ALLOW" 262 262 else : 263 263 action = "POLICY_DENY" 264 kotafilter.logger.log_message(_("User %s not registered in the PyKota system, applying default policy (%s) for printer %s") % (kotafilter.username, action, kotafilter.printername), "warn")264 thefilter.logger.log_message(_("User %s not registered in the PyKota system, applying default policy (%s) for printer %s") % (thefilter.username, action, thefilter.printername), "warn") 265 265 if action == "POLICY_DENY" : 266 return kotafilter.removeJob()266 return thefilter.removeJob() 267 267 else : 268 268 # Now does the accounting and act depending on the result 269 action = kotafilter.accounter.doAccounting(printer, user)269 action = thefilter.accounter.doAccounting(printer, user) 270 270 271 271 # if not allowed to print then die, else proceed. 272 272 if action == "DENY" : 273 273 # No, just die cleanly 274 return kotafilter.removeJob()274 return thefilter.removeJob() 275 275 276 276 # pass the job untouched to the underlying layer 277 kotafilter.accounter.filterInput(kotafilter.inputfile)277 thefilter.accounter.filterInput(thefilter.inputfile) 278 278 279 return kotafilter.acceptJob()279 return thefilter.acceptJob() 280 280 281 281 if __name__ == "__main__" : 282 282 retcode = -1 283 283 try : 284 retcode = main() 284 # Initializes the current tool 285 kotafilter = PyKotaFilter() 286 retcode = main(kotafilter) 285 287 except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError, PyKotaAccounterError, AttributeError, KeyError, IndexError, ValueError, IOError), msg : 286 288 sys.stderr.write("ERROR : PyKota filter failed (%s)\n" % msg) 287 289 sys.stderr.flush() 290 retcode = -1 291 292 try : 293 kotafilter.storage.close() 294 except (TypeError, NameError, AttributeError) : 295 pass 296 288 297 sys.exit(retcode) 289 -
pykota/trunk/bin/pykotme
r1099 r1113 23 23 # 24 24 # $Log$ 25 # Revision 1.3 2003/07/29 20:55:17 jalet 26 # 1.14 is out ! 27 # 25 28 # Revision 1.2 2003/07/25 10:41:29 jalet 26 29 # Better documentation. … … 150 153 151 154 if __name__ == "__main__" : 155 retcode = 0 152 156 try : 153 157 defaults = { \ … … 173 177 sender.display_version_and_quit() 174 178 else : 175 sys.exit(sender.main(args, options))179 retcode = sender.main(args, options) 176 180 except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError), msg : 177 181 sys.stderr.write("%s\n" % msg) 178 182 sys.stderr.flush() 179 sys.exit(-1)183 retcode = -1 180 184 185 try : 186 sender.storage.close() 187 except (TypeError, NameError, AttributeError) : 188 pass 189 190 sys.exit(retcode) -
pykota/trunk/bin/repykota
r1071 r1113 23 23 # 24 24 # $Log$ 25 # Revision 1.42 2003/07/29 20:55:17 jalet 26 # 1.14 is out ! 27 # 25 28 # Revision 1.41 2003/07/07 12:19:52 jalet 26 29 # Now repykota and warnpykota --groups check the groups the user is a member of … … 287 290 raise PyKotaToolError, _("incompatible options, see help.") 288 291 else : 289 sys.exit(reportTool.main(args, options))292 retcode = reportTool.main(args, options) 290 293 except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError, PyKotaReporterError), msg : 291 294 sys.stderr.write("%s\n" % msg) 292 295 sys.stderr.flush() 293 sys.exit(-1) 294 296 retcode = -1 297 298 try : 299 reportTool.storage.close() 300 except (TypeError, NameError, AttributeError) : 301 pass 302 303 sys.exit(retcode) -
pykota/trunk/bin/warnpykota
r1071 r1113 23 23 # 24 24 # $Log$ 25 # Revision 1.22 2003/07/29 20:55:17 jalet 26 # 1.14 is out ! 27 # 25 28 # Revision 1.21 2003/07/07 12:19:52 jalet 26 29 # Now repykota and warnpykota --groups check the groups the user is a member of … … 199 202 200 203 if __name__ == "__main__" : 204 retcode = 0 201 205 try : 202 206 defaults = { \ … … 226 230 raise PyKotaToolError, _("incompatible options, see help.") 227 231 else : 228 sys.exit(sender.main(args, options))232 retcode = sender.main(args, options) 229 233 except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError), msg : 230 234 sys.stderr.write("%s\n" % msg) 231 235 sys.stderr.flush() 232 sys.exit(-1) 233 236 retcode = -1 237 238 try : 239 sender.storage.close() 240 except (TypeError, NameError, AttributeError) : 241 pass 242 243 sys.exit(retcode)