Changeset 3052 for pykota/trunk/bin
- Timestamp:
- 11/08/06 23:44:53 (18 years ago)
- Location:
- pykota/trunk/bin
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkbcodes
r2829 r3052 107 107 billingcodes = self.storage.getMatchingBillingCodes(",".join(names)) 108 108 if not billingcodes : 109 if not options["list"] : 110 percent.display("\n") 109 111 raise PyKotaCommandLineError, _("There's no billingcode matching %s") % " ".join(names) 110 112 if not options["list"] : -
pykota/trunk/bin/pkprinters
r3051 r3052 149 149 def getPrinterDeviceURI(self, printername) : 150 150 """Returns the Device URI attribute for a particular printer.""" 151 if not printername : 152 return "" 151 153 cups = pkipplib.CUPS() 152 154 req = cups.newRequest(pkipplib.IPP_GET_PRINTER_ATTRIBUTES) … … 157 159 return "" 158 160 159 def isPrinterCaptured(self, printername ) :161 def isPrinterCaptured(self, printername=None, deviceuri=None) : 160 162 """Returns True if the printer is already redirected through PyKota's backend, else False.""" 161 if self.getPrinterDeviceURI(printername).find("cupspykota:") != -1 :163 if (deviceuri or self.getPrinterDeviceURI(printername)).find("cupspykota:") != -1 : 162 164 return True 163 165 else : … … 179 181 printers = self.storage.getMatchingPrinters(",".join(names)) 180 182 if not printers : 183 if not options["list"] : 184 percent.display("\n") 181 185 raise PyKotaCommandLineError, _("There's no printer matching %s") % " ".join(names) 182 186 if not options["list"] : … … 198 202 percent.display("\n%s..." % _("Deletion")) 199 203 self.storage.deleteManyPrinters(printers) 204 percent.display("\n%s...\n" % _("Rerouting printers to CUPS")) 205 for printer in printers : 206 uri = self.getPrinterDeviceURI(printer.Name) 207 if self.isPrinterCaptured(deviceuri=uri) : 208 newuri = uri.replace("cupspykota:", "") 209 if newuri.startswith("//") : 210 newuri = newuri[2:] 211 self.regainPriv() # to avoid having to enter password. 212 os.system('lpadmin -p "%s" -v "%s"' % (printer.Name, newuri)) 213 self.logdebug("Printer %s rerouted to %s" % (printer.Name, newuri)) 214 self.dropPriv() 215 percent.oneMore() 200 216 percent.display("\n") 201 217 else : … … 251 267 nopassthrough, maxjobsize) 252 268 oldprinter = self.storage.addPrinter(printer) 269 270 uri = self.getPrinterDeviceURI(printer.Name) 271 if not self.isPrinterCaptured(deviceuri=uri) : 272 newuri = "cupspykota://%s" % uri 273 self.regainPriv() # to avoid having to enter password. 274 os.system('lpadmin -p "%s" -v "%s"' % (printer.Name, newuri)) 275 self.logdebug("Printer %s rerouted to %s" % (printer.Name, newuri)) 276 self.dropPriv() 277 253 278 if oldprinter is not None : 254 279 if skipexisting : -
pykota/trunk/bin/pkusers
r2937 r3052 215 215 entries = getattr(self.storage, "getMatching%ss" % suffix)(",".join(names)) 216 216 if not entries : 217 if not options["list"] : 218 percent.display("\n") 217 219 raise PyKotaCommandLineError, _("There's no %s matching %s") % (_(suffix.lower()), " ".join(names)) 218 220 if not options["list"] :