Changeset 3105 for pykota/trunk
- Timestamp:
- 12/02/06 14:14:09 (18 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkprinters
r3073 r3105 168 168 return False 169 169 170 def reroutePrinterThroughPyKota(self, printer) : 171 """Reroutes a CUPS printer through PyKota.""" 172 uri = self.getPrinterDeviceURI(printer.Name) 173 if not self.isPrinterCaptured(deviceuri=uri) : 174 newuri = "cupspykota://%s" % uri 175 self.regainPriv() # to avoid having to enter password. 176 os.system('lpadmin -p "%s" -v "%s"' % (printer.Name, newuri)) 177 self.logdebug("Printer %s rerouted to %s" % (printer.Name, newuri)) 178 self.dropPriv() 179 180 def deroutePrinterFromPyKota(self, printer) : 181 """Deroutes a PyKota printer through CUPS only.""" 182 uri = self.getPrinterDeviceURI(printer.Name) 183 if self.isPrinterCaptured(deviceuri=uri) : 184 newuri = uri.replace("cupspykota:", "") 185 if newuri.startswith("//") : 186 newuri = newuri[2:] 187 self.regainPriv() # to avoid having to enter password. 188 os.system('lpadmin -p "%s" -v "%s"' % (printer.Name, newuri)) 189 self.logdebug("Printer %s rerouted to %s" % (printer.Name, newuri)) 190 self.dropPriv() 191 170 192 def main(self, names, options) : 171 193 """Manage printers.""" … … 206 228 percent.display("\n%s..." % _("Deletion")) 207 229 self.storage.deleteManyPrinters(printers) 230 percent.display("\n") 208 231 if docups : 209 percent.display(" \n%s...\n" % _("Rerouting printers to CUPS"))232 percent.display("%s...\n" % _("Rerouting printers to CUPS")) 210 233 for printer in printers : 211 uri = self.getPrinterDeviceURI(printer.Name) 212 if self.isPrinterCaptured(deviceuri=uri) : 213 newuri = uri.replace("cupspykota:", "") 214 if newuri.startswith("//") : 215 newuri = newuri[2:] 216 self.regainPriv() # to avoid having to enter password. 217 os.system('lpadmin -p "%s" -v "%s"' % (printer.Name, newuri)) 218 self.logdebug("Printer %s rerouted to %s" % (printer.Name, newuri)) 219 self.dropPriv() 234 self.deroutePrinterFromPyKota(printer) 220 235 percent.oneMore() 221 percent.display("\n")222 236 else : 223 237 if options["groups"] : … … 274 288 275 289 if docups : 276 uri = self.getPrinterDeviceURI(printer.Name) 277 if not self.isPrinterCaptured(deviceuri=uri) : 278 newuri = "cupspykota://%s" % uri 279 self.regainPriv() # to avoid having to enter password. 280 os.system('lpadmin -p "%s" -v "%s"' % (printer.Name, newuri)) 281 self.logdebug("Printer %s rerouted to %s" % (printer.Name, newuri)) 282 self.dropPriv() 290 self.reroutePrinterThroughPyKota(printer) 283 291 284 292 if oldprinter is not None : … … 308 316 printer.save() 309 317 self.managePrintersGroups(printersgroups, printer, remove) 318 if docups : 319 self.reroutePrinterThroughPyKota(printer) 310 320 percent.oneMore() 311 321 except :