| 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 | |
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) |