Show
Ignore:
Timestamp:
11/27/06 22:06:14 (17 years ago)
Author:
jerome
Message:

Now pkprinters doesn't modify CUPS' printers.conf if the -C | --cups
command line switch is not used.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkprinters

    r3052 r3073  
    5454   
    5555  -D | --description d Adds a textual description to printers. 
    56                         
     56 
     57  -C | --cups          Also modifies the DeviceURI in CUPS' printers.conf 
     58 
    5759  -c | --charge p[,j]  Sets the price per page and per job to charge. 
    5860                       Job price is optional. 
     
    171173            raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command.")) 
    172174             
     175        docups = options["cups"] 
     176         
    173177        if not options["list"] :     
    174178            percent = Percent(self) 
     
    202206            percent.display("\n%s..." % _("Deletion")) 
    203207            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() 
     208            if docups : 
     209                percent.display("\n%s...\n" % _("Rerouting printers to CUPS")) 
     210                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()     
     220                    percent.oneMore() 
    216221            percent.display("\n") 
    217222        else : 
     
    268273                            oldprinter = self.storage.addPrinter(printer)                
    269274                             
    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() 
     275                            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() 
    277283                                      
    278284                            if oldprinter is not None : 
     
    315321    retcode = 0 
    316322    try : 
    317         short_options = "hvac:D:dg:lrsnpm:" 
    318         long_options = ["help", "version", "add", "charge=", "description=", \ 
     323        short_options = "hvaCc:D:dg:lrsnpm:" 
     324        long_options = ["help", "version", "add", "cups", "charge=", "description=", \ 
    319325                        "delete", "groups=", "list", "remove", \ 
    320326                        "skipexisting", "passthrough", "nopassthrough", \ 
     
    332338        options["version"] = options["v"] or options["version"] 
    333339        options["add"] = options["a"] or options["add"] 
     340        options["cups"] = options["C"] or options["cups"] 
    334341        options["charge"] = options["c"] or options["charge"] 
    335342        options["description"] = options["D"] or options["description"]