Changeset 1258
- Timestamp:
- 01/08/04 17:24:49 (21 years ago)
- Location:
- pykota/trunk
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/edpykota
r1257 r1258 24 24 # 25 25 # $Log$ 26 # Revision 1.65 2004/01/08 16:24:49 jalet 27 # edpykota now supports adding printers to printer groups. 28 # 26 29 # Revision 1.64 2004/01/08 14:10:32 jalet 27 30 # Copyright year changed. … … 276 279 by separating them with commas. 277 280 278 -g | --groups Edit groups print quotas instead of users. 281 -G | --pgroups pg1[,pg2...] Adds the printer(s) to the printer groups 282 pg1, pg2, etc... which must already exist. 283 A printer group is just like a normal printer, 284 only that it is usually unknown from the printing 285 system. Create printer groups exactly the same 286 way that you create printers, then add other 287 printers to them with this option. 288 Accounting is done on a printer and on all 289 the printer groups it belongs to, quota checking 290 is done on a printer and on all the printer groups 291 it belongs to. 292 293 -g | --groups Edit users groups print quotas instead of users. 279 294 280 295 -p | --prototype u|g Uses user u or group g as a prototype to set … … 366 381 This will set the page price for printer lp to 0.1. Job price 367 382 will not be changed. 383 384 $ edpykota --printer hplj1,hplj2 --pgroups Laser,HP 385 386 This will put printers hplj1 and hplj2 in printers groups Laser and HP. 387 When printing either on hplj1 or hplj2, print quota will also be 388 checked and accounted for on virtual printers Laser and HP. 368 389 369 390 This program is free software; you can redistribute it and/or modify … … 464 485 names = [ "*" ] # all users 465 486 487 printersgroups = [] 488 if options["pgroups"] : 489 printersgroups = self.storage.getMatchingPrinters(options["pgroups"]) 490 466 491 changed = {} # tracks changes made at the user/group level 467 492 for printer in printers : 493 for pgroup in printersgroups : 494 pgroup.addPrinterToGroup(printer) 495 468 496 if options["charge"] : 469 497 (perpage, perjob) = charges … … 576 604 "printer" : "*", \ 577 605 } 578 short_options = "vhdc:l:b:i:naugrp:P:S:H: "579 long_options = ["help", "version", "charge=", "delete", "limitby=", "balance=", "ingroups=", "noquota", "add", "users", "groups", "reset", "prototype=", "printer=", "softlimit=", "hardlimit=" ]606 short_options = "vhdc:l:b:i:naugrp:P:S:H:G:" 607 long_options = ["help", "version", "charge=", "delete", "limitby=", "balance=", "ingroups=", "noquota", "add", "users", "groups", "reset", "prototype=", "printer=", "softlimit=", "hardlimit=", "pgroups="] 580 608 581 609 # Initializes the command line tool … … 602 630 options["ingroups"] = options["i"] or options["ingroups"] 603 631 options["charge"] = options["c"] or options["charge"] 632 options["pgroups"] = options["G"] or options["pgroups"] 604 633 605 634 if options["help"] : -
pykota/trunk/NEWS
r1257 r1258 22 22 PyKota NEWS : 23 23 24 - 1.16alpha22 : 25 26 - edpykota now allows adding printers to printer groups 27 24 28 - 1.16alpha21 : 25 29 -
pykota/trunk/pykota/storage.py
r1257 r1258 22 22 # 23 23 # $Log$ 24 # Revision 1.34 2004/01/08 16:24:49 jalet 25 # edpykota now supports adding printers to printer groups. 26 # 24 27 # Revision 1.33 2004/01/08 14:10:32 jalet 25 28 # Copyright year changed. … … 239 242 self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options) 240 243 # TODO : update LastJob object ? Probably not needed. 244 245 def addPrinterToGroup(self, printer) : 246 """Adds a printer to a printer group.""" 247 if printer not in self.parent.getParentPrinters(self) : 248 self.parent.writePrinterToGroup(self, printer) 241 249 242 250 def setPrices(self, priceperpage = None, priceperjob = None) : -
pykota/trunk/pykota/storages/ldapstorage.py
r1257 r1258 22 22 # 23 23 # $Log$ 24 # Revision 1.45 2004/01/08 16:24:49 jalet 25 # edpykota now supports adding printers to printer groups. 26 # 24 27 # Revision 1.44 2004/01/08 14:10:33 jalet 25 28 # Copyright year changed. … … 361 364 """Extracts printer information given its name.""" 362 365 printer = StoragePrinter(self, printername) 363 result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPricePerPage", "pykotaPricePerJob" ], base=self.info["printerbase"])366 result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember"], base=self.info["printerbase"]) 364 367 if result : 365 368 fields = result[0][1] … … 368 371 printer.PricePerPage = float(fields.get("pykotaPricePerPage")[0] or 0.0) 369 372 printer.LastJob = self.getPrinterLastJob(printer) 373 printer.uniqueMember = fields.get("uniqueMember", []) 370 374 printer.Exists = 1 371 375 return printer … … 521 525 printers = [] 522 526 # see comment at the same place in pgstorage.py 523 result = self.doSearch("(&(objectClass=pykotaPrinter)(|%s))" % "".join(["(pykotaPrinterName=%s)" % pname for pname in printerpattern.split(",")]), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob" ], base=self.info["printerbase"])527 result = self.doSearch("(&(objectClass=pykotaPrinter)(|%s))" % "".join(["(pykotaPrinterName=%s)" % pname for pname in printerpattern.split(",")]), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember"], base=self.info["printerbase"]) 524 528 if result : 525 529 for (printerid, fields) in result : … … 529 533 printer.PricePerJob = float(fields.get("pykotaPricePerJob")[0] or 0.0) 530 534 printer.PricePerPage = float(fields.get("pykotaPricePerPage")[0] or 0.0) 535 printer.uniqueMember = fields.get("uniqueMember", []) 531 536 printer.LastJob = self.getPrinterLastJob(printer) 532 537 printer.Exists = 1 … … 814 819 self.doModify(grouppquota.ident, fields) 815 820 821 def writePrinterToGroup(self, pgroup, printer) : 822 """Puts a printer into a printer group.""" 823 if (printer.ident not in pgroup.uniqueMember) and (printer.ident != pgroup.ident) : 824 fields = { 825 "uniqueMember" : pgroup.uniqueMember + [printer.ident] 826 } 827 self.doModify(pgroup.ident, fields) 828 816 829 def deleteUser(self, user) : 817 830 """Completely deletes an user from the Quota Storage.""" -
pykota/trunk/pykota/storages/pgstorage.py
r1257 r1258 22 22 # 23 23 # $Log$ 24 # Revision 1.29 2004/01/08 16:24:49 jalet 25 # edpykota now supports adding printers to printer groups. 26 # 24 27 # Revision 1.28 2004/01/08 14:10:33 jalet 25 28 # Copyright year changed. … … 505 508 self.doModify("UPDATE grouppquota SET softlimit=%s, hardlimit=%s, datelimit=NULL WHERE id=%s" % (self.doQuote(softlimit), self.doQuote(hardlimit), self.doQuote(grouppquota.ident))) 506 509 510 def writePrinterToGroup(self, pgroup, printer) : 511 """Puts a printer into a printer group.""" 512 self.doModify("INSERT INTO printergroupsmembers (groupid, printerid) VALUES (%s, %s);" % (self.doQuote(pgroup.ident), self.doQuote(printer.ident))) 513 507 514 def deleteUser(self, user) : 508 515 """Completely deletes an user from the Quota Storage.""" -
pykota/trunk/pykota/version.py
r1257 r1258 22 22 # 23 23 24 __version__ = "1.16alpha2 1_unofficial"24 __version__ = "1.16alpha22_unofficial" 25 25 26 26 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""