Changeset 1332
- Timestamp:
- 02/04/04 14:24:41 (21 years ago)
- Location:
- pykota/trunk
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkprinters
r1331 r1332 24 24 # 25 25 # $Log$ 26 # Revision 1.3 2004/02/04 13:24:41 jalet 27 # pkprinters can now remove printers from printers groups. 28 # 26 29 # Revision 1.2 2004/02/04 12:52:37 jalet 27 30 # pkprinters' help … … 62 65 Floating point and negative values are allowed. 63 66 64 -g | --groups pg1[,pg2...] Adds the printer(s) to the printer groups65 pg1, pg2, etc... which must already exist.67 -g | --groups pg1[,pg2...] Adds or Remove the printer(s) to the printer 68 groups pg1, pg2, etc... which must already exist. 66 69 A printer group is just like a normal printer, 67 70 only that it is usually unknown from the printing … … 73 76 is done on a printer and on all the printer groups 74 77 it belongs to. 78 If the --remove option below is not used, the 79 default action is to add printers to the specified 80 printer groups. 81 82 -r | --remove In combination with the --groups option above, 83 remove printers from the specified printers groups. 75 84 76 85 printer1 through printerN can contain wildcards if the --add option … … 96 105 This will put all printers which name matches "hp*" into printers groups 97 106 Laser and HP, which MUST already exist. 107 108 $ pkprinters --groups LexMark --remove hp2200 109 110 This will remove the hp2200 printer from the LexMark printer group. 98 111 99 112 This program is free software; you can redistribute it and/or modify … … 159 172 if options["groups"] : 160 173 for pgroup in printersgroups : 161 pgroup.addPrinterToGroup(printer) 174 if options["remove"] : 175 pgroup.delPrinterFromGroup(printer) 176 else : 177 pgroup.addPrinterToGroup(printer) 162 178 163 179 if __name__ == "__main__" : 164 180 retcode = 0 165 181 try : 166 short_options = "hvac:dg: "167 long_options = ["help", "version", "add", "charge=", "delete", "groups=" ]182 short_options = "hvac:dg:r" 183 long_options = ["help", "version", "add", "charge=", "delete", "groups=", "remove"] 168 184 169 185 # Initializes the command line tool … … 180 196 options["delete"] = options["d"] or options["delete"] 181 197 options["groups"] = options["g"] or options["groups"] 198 options["remove"] = options["r"] or options["remove"] 182 199 183 200 if options["help"] : … … 185 202 elif options["version"] : 186 203 manager.display_version_and_quit() 187 elif options["delete"] and (options["add"] or options["groups"] or options["charge"] ) :204 elif options["delete"] and (options["add"] or options["groups"] or options["charge"] or options["remove"]) : 188 205 raise PyKotaToolError, _("incompatible options, see help.") 206 elif options["remove"] and not options["groups"] : 207 raise PyKotaToolError, _("You have to pass printer groups names on the command line") 189 208 elif not args : 190 209 raise PyKotaToolError, _("You have to pass printer names on the command line") -
pykota/trunk/man/pkprinters.1
r1331 r1332 32 32 Floating point and negative values are allowed. 33 33 .TP 34 \fB\-g\fR | \fB\-\-groups\fR pg1[,pg2...] Adds the printer(s) to the printer groups35 pg1, pg2, etc... which must already exist.34 \fB\-g\fR | \fB\-\-groups\fR pg1[,pg2...] Adds or Remove the printer(s) to the printer 35 groups pg1, pg2, etc... which must already exist. 36 36 A printer group is just like a normal printer, 37 37 only that it is usually unknown from the printing … … 43 43 is done on a printer and on all the printer groups 44 44 it belongs to. 45 If the \fB\-\-remove\fR option below is not used, the 46 default action is to add printers to the specified 47 printer groups. 48 .TP 49 \fB\-r\fR | \fB\-\-remove\fR 50 In combination with the \fB\-\-groups\fR option above, 51 remove printers from the specified printers groups. 45 52 .IP 46 53 printer1 through printerN can contain wildcards if the \fB\-\-add\fR option … … 66 73 This will put all printers which name matches "hp*" into printers groups 67 74 Laser and HP, which MUST already exist. 75 .IP 76 \f(CW$ pkprinters --groups LexMark --remove hp2200\fR 77 .IP 78 This will remove the hp2200 printer from the LexMark printer group. 68 79 .PP 69 80 This program is free software; you can redistribute it and/or modify -
pykota/trunk/pykota/storage.py
r1330 r1332 22 22 # 23 23 # $Log$ 24 # Revision 1.40 2004/02/04 13:24:41 jalet 25 # pkprinters can now remove printers from printers groups. 26 # 24 27 # Revision 1.39 2004/02/04 11:16:59 jalet 25 28 # pkprinters command line tool added. … … 262 265 if (printer not in self.parent.getParentPrinters(self)) and (printer.ident != self.ident) : 263 266 self.parent.writePrinterToGroup(self, printer) 267 # TODO : reset cached value for printer parents, or add new parent to cached value 268 269 def delPrinterFromGroup(self, printer) : 270 """Deletes a printer from a printer group.""" 271 if (printer in self.parent.getParentPrinters(self)) and (printer.ident != self.ident) : 272 self.parent.removePrinterFromGroup(self, printer) 264 273 # TODO : reset cached value for printer parents, or add new parent to cached value 265 274 -
pykota/trunk/pykota/storages/ldapstorage.py
r1330 r1332 22 22 # 23 23 # $Log$ 24 # Revision 1.51 2004/02/04 13:24:41 jalet 25 # pkprinters can now remove printers from printers groups. 26 # 24 27 # Revision 1.50 2004/02/04 11:17:00 jalet 25 28 # pkprinters command line tool added. … … 871 874 self.doModify(pgroup.ident, fields) 872 875 876 def removePrinterFromGroup(self, pgroup, printer) : 877 """Removes a printer from a printer group.""" 878 try : 879 pgroup.uniqueMember.remove(printer.ident) 880 except ValueError : 881 pass 882 else : 883 fields = { 884 "uniqueMember" : pgroup.uniqueMember, 885 } 886 self.doModify(pgroup.ident, fields) 887 873 888 def retrieveHistory(self, user=None, printer=None, datelimit=None, limit=100) : 874 889 """Retrieves all print jobs for user on printer (or all) before date, limited to first 100 results.""" … … 993 1008 self.doDelete(ident) 994 1009 for parent in self.getParentPrinters(printer) : 995 parent.uniqueMember.remove(printer.ident) 996 fields = { 997 "uniqueMember" : parent.uniqueMember, 998 } 999 self.doModify(parent.ident, fields) 1010 try : 1011 parent.uniqueMember.remove(printer.ident) 1012 except ValueError : 1013 pass 1014 else : 1015 fields = { 1016 "uniqueMember" : parent.uniqueMember, 1017 } 1018 self.doModify(parent.ident, fields) 1000 1019 self.doDelete(printer.ident) -
pykota/trunk/pykota/storages/sql.py
r1330 r1332 22 22 # 23 23 # $Log$ 24 # Revision 1.36 2004/02/04 13:24:41 jalet 25 # pkprinters can now remove printers from printers groups. 26 # 24 27 # Revision 1.35 2004/02/04 11:17:00 jalet 25 28 # pkprinters command line tool added. … … 353 356 self.doModify("INSERT INTO printergroupsmembers (groupid, printerid) VALUES (%s, %s)" % (self.doQuote(pgroup.ident), self.doQuote(printer.ident))) 354 357 358 def removePrinterFromGroup(self, pgroup, printer) : 359 """Removes a printer from a printer group.""" 360 self.doModify("DELETE FROM printergroupsmembers WHERE groupid=%s AND printerid=%s" % (self.doQuote(pgroup.ident), self.doQuote(printer.ident))) 361 355 362 def retrieveHistory(self, user=None, printer=None, datelimit=None, limit=100) : 356 363 """Retrieves all print jobs for user on printer (or all) before date, limited to first 100 results."""