Changeset 1582
- Timestamp:
- 07/01/04 19:45:49 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 14 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkprinters
r1546 r1582 24 24 # 25 25 # $Log$ 26 # Revision 1.12 2004/07/01 17:45:47 jalet 27 # Added code to handle the description field for printers 28 # 26 29 # Revision 1.11 2004/06/18 13:34:48 jalet 27 30 # Now all tracebacks include PyKota's version number … … 87 90 88 91 -d | --delete Deletes printers from the quota storage. 92 93 -D | --description Adds a textual description to printers. 89 94 90 95 -c | --charge p[,j] Sets the price per page and per job to charge. … … 122 127 examples : 123 128 124 $ pkprinters --add - -charge 0.05,0.1 hp2100 hp2200 hp8000129 $ pkprinters --add -D "HP Printer" --charge 0.05,0.1 hp2100 hp2200 hp8000 125 130 126 131 Will create three printers named hp2100, hp2200 and hp8000. … … 128 133 per job will be set at 0.1 unit. Units are in your own currency, 129 134 or whatever you want them to mean. 130 If any of these printers already exists, it is not modified at 131 all. 135 All of their descriptions will be set to the string "HP Printer". 136 If any of these printers already exists, it will also be modified 137 unless the -s|--skipexisting command line option is also used. 132 138 133 139 $ pkprinters --delete "*" … … 191 197 if printer.Exists : 192 198 if options["skipexisting"] : 193 self. logger.log_message(_("Printer %s already exists, skipping.") % printer.Name, "warn")199 self.printError(_("Printer %s already exists, skipping.") % printer.Name) 194 200 else : 195 self. logger.log_message(_("Printer %s already exists, will be modified.") % printer.Name, "warn")201 self.printError(_("Printer %s already exists, will be modified.") % printer.Name) 196 202 printers.append(printer) 197 203 else : … … 216 222 if parents : 217 223 parents = "%s %s" % (_("in"), parents) 218 print "%s (%s + #*%s) %s" % \219 (printer.Name, printer. PricePerJob, \224 print "%s [%s] (%s + #*%s) %s" % \ 225 (printer.Name, printer.Description, printer.PricePerJob, \ 220 226 printer.PricePerPage, parents) 221 227 else : 222 228 if options["charge"] : 223 229 printer.setPrices(perpage, perjob) 230 if options["description"] is not None : 231 printer.setDescription(options["description"].strip()) 224 232 if options["groups"] : 225 233 for pgroup in printersgroups : … … 232 240 retcode = 0 233 241 try : 234 short_options = "hvac: dg:lrs"235 long_options = ["help", "version", "add", "charge=", "de lete", "groups=", "list", "remove", "skipexisting"]242 short_options = "hvac:D:dg:lrs" 243 long_options = ["help", "version", "add", "charge=", "description=", "delete", "groups=", "list", "remove", "skipexisting"] 236 244 237 245 # Initializes the command line tool … … 246 254 options["add"] = options["a"] or options["add"] 247 255 options["charge"] = options["c"] or options["charge"] 256 options["description"] = options["D"] or options["description"] 248 257 options["delete"] = options["d"] or options["delete"] 249 258 options["groups"] = options["g"] or options["groups"] … … 256 265 elif options["version"] : 257 266 manager.display_version_and_quit() 258 elif (options["delete"] and (options["add"] or options["groups"] or options["charge"] or options["remove"] )) \267 elif (options["delete"] and (options["add"] or options["groups"] or options["charge"] or options["remove"] or options["description"])) \ 259 268 or (options["skipexisting"] and not options["add"]) \ 260 or (options["list"] and (options["add"] or options["delete"] or options["groups"] or options["charge"] or options["remove"] )) :269 or (options["list"] and (options["add"] or options["delete"] or options["groups"] or options["charge"] or options["remove"] or options["description"])) : 261 270 raise PyKotaToolError, _("incompatible options, see help.") 262 271 elif options["remove"] and not options["groups"] : -
pykota/trunk/cgi-bin/printquota.cgi
r1525 r1582 23 23 # 24 24 # $Log$ 25 # Revision 1.30 2004/07/01 17:45:48 jalet 26 # Added code to handle the description field for printers 27 # 25 28 # Revision 1.29 2004/06/06 21:07:55 jalet 26 29 # Improved CGI script to allow history on printers and hostnames. … … 189 192 for printer in printers : 190 193 if printer.Name in selectednames : 191 message += '<option value="%s" selected="selected">%s </option>' % (printer.Name, printer.Name)194 message += '<option value="%s" selected="selected">%s (%s)</option>' % (printer.Name, printer.Name, printer.Description) 192 195 else : 193 message += '<option value="%s">%s </option>' % (printer.Name, printer.Name)196 message += '<option value="%s">%s (%s)</option>' % (printer.Name, printer.Name, printer.Description) 194 197 message += '</select></td></tr></table>' 195 198 return message -
pykota/trunk/man/edpykota.1
r1578 r1582 1 1 .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.33. 2 .TH EDPYKOTA "1" "Ju ne2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"2 .TH EDPYKOTA "1" "July 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands" 3 3 .SH NAME 4 4 edpykota \- manual page for edpykota 1.19alpha28_unofficial -
pykota/trunk/man/pkhint.1
r1578 r1582 1 1 .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.33. 2 .TH PKHINT "1" "Ju ne2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"2 .TH PKHINT "1" "July 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands" 3 3 .SH NAME 4 4 pkhint \- manual page for pkhint 1.19alpha28_unofficial -
pykota/trunk/man/pkprinters.1
r1578 r1582 1 1 .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.33. 2 .TH PKPRINTERS "1" "Ju ne2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"2 .TH PKPRINTERS "1" "July 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands" 3 3 .SH NAME 4 4 pkprinters \- manual page for pkprinters 1.19alpha28_unofficial … … 26 26 \fB\-d\fR | \fB\-\-delete\fR 27 27 Deletes printers from the quota storage. 28 .TP 29 \fB\-D\fR | \fB\-\-description\fR 30 Adds a textual description to printers. 28 31 .TP 29 32 \fB\-c\fR | \fB\-\-charge\fR p[,j] … … 65 68 examples : 66 69 .IP 67 \f(CW$ pkprinters --add - -charge 0.05,0.1 hp2100 hp2200 hp8000\fR70 \f(CW$ pkprinters --add -D "HP Printer" --charge 0.05,0.1 hp2100 hp2200 hp8000\fR 68 71 .IP 69 72 Will create three printers named hp2100, hp2200 and hp8000. … … 71 74 per job will be set at 0.1 unit. Units are in your own currency, 72 75 or whatever you want them to mean. 73 If any of these printers already exists, it is not modified at 74 all. 76 All of their descriptions will be set to the string "HP Printer". 77 If any of these printers already exists, it will also be modified 78 unless the \fB\-s\fR|--skipexisting command line option is also used. 75 79 .IP 76 80 \f(CW$ pkprinters --delete "*"\fR -
pykota/trunk/man/pykotme.1
r1578 r1582 1 1 .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.33. 2 .TH PYKOTME "1" "Ju ne2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"2 .TH PYKOTME "1" "July 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands" 3 3 .SH NAME 4 4 pykotme \- manual page for pykotme 1.19alpha28_unofficial -
pykota/trunk/man/repykota.1
r1578 r1582 1 1 .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.33. 2 .TH REPYKOTA "1" "Ju ne2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"2 .TH REPYKOTA "1" "July 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands" 3 3 .SH NAME 4 4 repykota \- manual page for repykota 1.19alpha28_unofficial -
pykota/trunk/man/warnpykota.1
r1578 r1582 1 1 .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.33. 2 .TH WARNPYKOTA "1" "Ju ne2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"2 .TH WARNPYKOTA "1" "July 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands" 3 3 .SH NAME 4 4 warnpykota \- manual page for warnpykota 1.19alpha28_unofficial -
pykota/trunk/NEWS
r1578 r1582 24 24 - 1.19alpha28 : 25 25 26 - The description field for printers can now be set, 27 and is displayed in reports. 28 29 - Fixed a small problem in SQL backend code. 30 26 31 - Improved pkhint 27 32 -
pykota/trunk/pykota/reporter.py
r1418 r1582 22 22 # 23 23 # $Log$ 24 # Revision 1.9 2004/07/01 17:45:49 jalet 25 # Added code to handle the description field for printers 26 # 24 27 # Revision 1.8 2004/03/24 15:15:24 jalet 25 28 # Began integration of Henrik Janhagen's work on quota-then-balance … … 70 73 71 74 def getPrinterTitle(self, printer) : 72 return _("Report for %s quota on printer %s") % ((self.isgroup and "group") or "user", printer.Name)75 return (_("Report for %s quota on printer %s") % ((self.isgroup and "group") or "user", printer.Name)) + (" (%s)" % printer.Description) 73 76 74 77 def getPrinterGraceDelay(self, printer) : … … 100 103 balance = float(entry.AccountBalance or 0.0) 101 104 lifetimepaid = float(entry.LifeTimePaid or 0.0) 102 105 103 106 #balance 104 107 if entry.LimitBy and (entry.LimitBy.lower() == "balance") : -
pykota/trunk/pykota/storage.py
r1523 r1582 22 22 # 23 23 # $Log$ 24 # Revision 1.56 2004/07/01 17:45:49 jalet 25 # Added code to handle the description field for printers 26 # 24 27 # Revision 1.55 2004/06/05 22:18:04 jalet 25 28 # Now catches some exceptions earlier. … … 317 320 self.PricePerPage = None 318 321 self.PricePerJob = None 322 self.Description = None 319 323 320 324 def __getattr__(self, name) : … … 353 357 self.PricePerJob = float(priceperjob) 354 358 self.parent.writePrinterPrices(self) 359 360 def setDescription(self, description = None) : 361 """Sets the printer's prices.""" 362 if description is None : 363 description = self.Description 364 else : 365 self.Description = str(description) 366 self.parent.writePrinterDescription(self) 355 367 356 368 def delete(self) : -
pykota/trunk/pykota/storages/ldapstorage.py
r1534 r1582 22 22 # 23 23 # $Log$ 24 # Revision 1.71 2004/07/01 17:45:49 jalet 25 # Added code to handle the description field for printers 26 # 24 27 # Revision 1.70 2004/06/10 20:50:25 jalet 25 28 # Better log message … … 535 538 """Extracts printer information given its name : returns first matching printer.""" 536 539 printer = StoragePrinter(self, printername) 537 result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember" ], base=self.info["printerbase"])540 result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember", "description"], base=self.info["printerbase"]) 538 541 if result : 539 542 fields = result[0][1] # take only first matching printer, ignore the rest … … 543 546 printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 544 547 printer.uniqueMember = fields.get("uniqueMember", []) 548 printer.Description = fields.get("description", [""])[0] 545 549 printer.Exists = 1 546 550 return printer … … 700 704 printers = [] 701 705 # see comment at the same place in pgstorage.py 702 result = self.doSearch("(&(objectClass=pykotaPrinter)(|%s))" % "".join(["(pykotaPrinterName=%s)(%s=%s)" % (pname, self.info["printerrdn"], pname) for pname in printerpattern.split(",")]), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember" ], base=self.info["printerbase"])706 result = self.doSearch("(&(objectClass=pykotaPrinter)(|%s))" % "".join(["(pykotaPrinterName=%s)(%s=%s)" % (pname, self.info["printerrdn"], pname) for pname in printerpattern.split(",")]), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember", "description"], base=self.info["printerbase"]) 703 707 if result : 704 708 for (printerid, fields) in result : … … 709 713 printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 710 714 printer.uniqueMember = fields.get("uniqueMember", []) 715 printer.Description = fields.get("description", [""])[0] 711 716 printer.Exists = 1 712 717 printers.append(printer) … … 895 900 "pykotaPricePerPage" : str(printer.PricePerPage), 896 901 "pykotaPricePerJob" : str(printer.PricePerJob), 902 } 903 self.doModify(printer.ident, fields) 904 905 def writePrinterDescription(self, printer) : 906 """Write the printer's description back into the storage.""" 907 fields = { 908 "description" : str(printer.Description), 897 909 } 898 910 self.doModify(printer.ident, fields) -
pykota/trunk/pykota/storages/sql.py
r1531 r1582 22 22 # 23 23 # $Log$ 24 # Revision 1.43 2004/07/01 17:45:49 jalet 25 # Added code to handle the description field for printers 26 # 24 27 # Revision 1.42 2004/06/08 17:44:43 jalet 25 28 # Payment now gets deleted when the user is deleted … … 115 118 printer.ident = fields.get("id") 116 119 printer.Name = fields.get("printername", printername) 117 printer.PricePerJob = fields.get("priceperjob") 118 printer.PricePerPage = fields.get("priceperpage") 120 printer.PricePerJob = fields.get("priceperjob") or 0.0 121 printer.PricePerPage = fields.get("priceperpage") or 0.0 122 printer.Description = fields.get("description") or "" 119 123 printer.Exists = 1 120 124 return printer … … 228 232 printer = StoragePrinter(self, record["printername"]) 229 233 printer.ident = record.get("id") 230 printer.PricePerJob = record.get("priceperjob") 231 printer.PricePerPage = record.get("priceperpage") 234 printer.PricePerJob = record.get("priceperjob") or 0.0 235 printer.PricePerPage = record.get("priceperpage") or 0.0 236 printer.Description = record.get("description") or "" 232 237 printer.Exists = 1 233 238 printers.append(printer) … … 313 318 self.doModify("UPDATE printers SET priceperpage=%s, priceperjob=%s WHERE id=%s" % (self.doQuote(printer.PricePerPage), self.doQuote(printer.PricePerJob), self.doQuote(printer.ident))) 314 319 320 def writePrinterDescription(self, printer) : 321 """Write the printer's description back into the storage.""" 322 self.doModify("UPDATE printers SET description=%s WHERE id=%s" % (self.doQuote(printer.Description), self.doQuote(printer.ident))) 323 315 324 def writeUserLimitBy(self, user, limitby) : 316 325 """Sets the user's limiting factor.""" -
pykota/trunk/pykota/tool.py
r1565 r1582 22 22 # 23 23 # $Log$ 24 # Revision 1.109 2004/07/01 17:45:49 jalet 25 # Added code to handle the description field for printers 26 # 24 27 # Revision 1.108 2004/06/24 23:09:30 jalet 25 28 # Also prints read size on last block … … 475 478 if self.debug : 476 479 self.logger.log_message(message, "debug") 480 481 def printError(self, message) : 482 """Sends a message to standard error.""" 483 sys.stderr.write("%s\n" % message) 484 sys.stderr.flush() 477 485 478 486 def clean(self) :