Changeset 3105

Show
Ignore:
Timestamp:
12/02/06 14:14:09 (17 years ago)
Author:
jerome
Message:

Didn't reroute printers with --cups in modification mode.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkprinters

    r3073 r3105  
    168168            return False 
    169169         
     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                                      
    170192    def main(self, names, options) : 
    171193        """Manage printers.""" 
     
    206228            percent.display("\n%s..." % _("Deletion")) 
    207229            self.storage.deleteManyPrinters(printers) 
     230            percent.display("\n") 
    208231            if docups : 
    209                 percent.display("\n%s...\n" % _("Rerouting printers to CUPS")) 
     232                percent.display("%s...\n" % _("Rerouting printers to CUPS")) 
    210233                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) 
    220235                    percent.oneMore() 
    221             percent.display("\n") 
    222236        else : 
    223237            if options["groups"] :         
     
    274288                             
    275289                            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) 
    283291                                      
    284292                            if oldprinter is not None : 
     
    308316                        printer.save()     
    309317                        self.managePrintersGroups(printersgroups, printer, remove) 
     318                        if docups : 
     319                            self.reroutePrinterThroughPyKota(printer) 
    310320                        percent.oneMore() 
    311321            except :