Index: pykota/trunk/bin/pkprinters
===================================================================
--- pykota/trunk/bin/pkprinters (revision 2622)
+++ pykota/trunk/bin/pkprinters (revision 2657)
@@ -129,90 +129,99 @@
             raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command."))
             
-        if options["list"] and not names :
-            names = ["*"]
-            
-        if options["groups"] :        
-            printersgroups = self.storage.getMatchingPrinters(options["groups"])
-            if not printersgroups :
-                raise PyKotaCommandLineError, _("There's no printer matching %s") % " ".join(options["groups"].split(','))
-            
-        if options["charge"] :
-            try :
-                charges = [float(part) for part in options["charge"].split(',', 1)]
-            except ValueError :    
-                raise PyKotaCommandLineError, _("Invalid charge amount value %s") % options["charge"]
-            else :    
-                if len(charges) > 2 :
-                    charges = charges[:2]
-                if len(charges) != 2 :
-                    charges = [charges[0], None]
-                (perpage, perjob) = charges
+        if options["delete"] :    
+            self.display("Processing...\n")
+            todelete = self.storage.getMatchingPrinters(",".join(names))
+            nbtotal = len(todelete)
+            for i in range(nbtotal) :
+                todelete[i].delete()
+                percent = 100.0 * float(i) / float(nbtotal)
+                self.display("\r%.02f%%" % percent)
+            self.display("\r100.00%%\r        ")
+            self.display("\r%s\n" % _("Done."))
+        else :
+            if options["list"] and not names :
+                names = ["*"]
                 
-        if options["maxjobsize"] :        
-            try :
-                maxjobsize = int(options["maxjobsize"])
-                if maxjobsize < 0 :
-                    raise ValueError
-            except ValueError :    
-                raise PyKotaCommandLineError, _("Invalid maximum job size value %s") % options["maxjobsize"]
-        else :        
-            maxjobsize = None
+            if options["groups"] :        
+                printersgroups = self.storage.getMatchingPrinters(options["groups"])
+                if not printersgroups :
+                    raise PyKotaCommandLineError, _("There's no printer matching %s") % " ".join(options["groups"].split(','))
                 
-                
-        if options["add"] :    
-            printers = []
-            for pname in names :
-                printer = self.storage.getPrinter(pname)
-                if printer.Exists :
-                    if options["skipexisting"] :
-                        self.printInfo(_("Printer %s already exists, skipping.") % printer.Name)
-                    else :    
-                        self.printInfo(_("Printer %s already exists, will be modified.") % printer.Name)
-                        printers.append(printer)
-                else :
-                    if self.isValidName(pname) :
-                        printer = self.storage.addPrinter(pname)
-                        if not printer.Exists :
-                            raise PyKotaToolError, _("Impossible to add printer %s") % pname
+            if options["charge"] :
+                try :
+                    charges = [float(part) for part in options["charge"].split(',', 1)]
+                except ValueError :    
+                    raise PyKotaCommandLineError, _("Invalid charge amount value %s") % options["charge"]
+                else :    
+                    if len(charges) > 2 :
+                        charges = charges[:2]
+                    if len(charges) != 2 :
+                        charges = [charges[0], None]
+                    (perpage, perjob) = charges
+                    
+            if options["maxjobsize"] :        
+                try :
+                    maxjobsize = int(options["maxjobsize"])
+                    if maxjobsize < 0 :
+                        raise ValueError
+                except ValueError :    
+                    raise PyKotaCommandLineError, _("Invalid maximum job size value %s") % options["maxjobsize"]
+            else :        
+                maxjobsize = None
+                    
+                    
+            if options["add"] :    
+                printers = []
+                for pname in names :
+                    printer = self.storage.getPrinter(pname)
+                    if printer.Exists :
+                        if options["skipexisting"] :
+                            self.printInfo(_("Printer %s already exists, skipping.") % printer.Name)
                         else :    
+                            self.printInfo(_("Printer %s already exists, will be modified.") % printer.Name)
                             printers.append(printer)
-                    else :    
-                        raise PyKotaCommandLineError, _("Invalid printer name %s") % pname
-        else :        
-            printers = self.storage.getMatchingPrinters(",".join(names))
-            if not printers :
-                raise PyKotaCommandLineError, _("There's no printer matching %s") % " ".join(names)
-                    
-        for printer in printers :        
-            if options["delete"] :
-                printer.delete()
-            elif options["list"] :    
-                parents = ", ".join([p.Name for p in self.storage.getParentPrinters(printer)])
-                if parents : 
-                    parents = "%s %s" % (_("in"), parents)
-                print "%s [%s] (%s + #*%s)" % \
-                      (printer.Name, printer.Description, printer.PricePerJob, \
-                       printer.PricePerPage)
-                print "    %s" % (_("Passthrough mode : %s") % ((printer.PassThrough and _("ON")) or _("OFF")))
-                print "    %s" % (_("Maximum job size : %s") % ((printer.MaxJobSize and (_("%s pages") % printer.MaxJobSize)) or _("Unlimited")))
-                if parents :       
-                    print "    %s" % parents
-            else :    
-                if options["charge"] :
-                    printer.setPrices(perpage, perjob)    
-                if options["description"] is not None :
-                    printer.setDescription(options["description"].strip())
-                if options["nopassthrough"] and printer.PassThrough :    
-                    self.storage.setPrinterPassThroughMode(printer, 0)
-                if options["passthrough"] and not printer.PassThrough :    
-                    self.storage.setPrinterPassThroughMode(printer, 1)
-                if (maxjobsize is not None) and (printer.MaxJobSize != maxjobsize) :    
-                    self.storage.setPrinterMaxJobSize(printer, maxjobsize)
-                if options["groups"] :    
-                    for pgroup in printersgroups :
-                        if options["remove"] :
-                            pgroup.delPrinterFromGroup(printer)
-                        else :
-                            pgroup.addPrinterToGroup(printer)    
+                    else :
+                        if self.isValidName(pname) :
+                            printer = self.storage.addPrinter(pname)
+                            if not printer.Exists :
+                                raise PyKotaToolError, _("Impossible to add printer %s") % pname
+                            else :    
+                                printers.append(printer)
+                        else :    
+                            raise PyKotaCommandLineError, _("Invalid printer name %s") % pname
+            else :        
+                printers = self.storage.getMatchingPrinters(",".join(names))
+                if not printers :
+                    raise PyKotaCommandLineError, _("There's no printer matching %s") % " ".join(names)
+                        
+            for printer in printers :        
+                if options["list"] :    
+                    parents = ", ".join([p.Name for p in self.storage.getParentPrinters(printer)])
+                    if parents : 
+                        parents = "%s %s" % (_("in"), parents)
+                    print "%s [%s] (%s + #*%s)" % \
+                          (printer.Name, printer.Description, printer.PricePerJob, \
+                           printer.PricePerPage)
+                    print "    %s" % (_("Passthrough mode : %s") % ((printer.PassThrough and _("ON")) or _("OFF")))
+                    print "    %s" % (_("Maximum job size : %s") % ((printer.MaxJobSize and (_("%s pages") % printer.MaxJobSize)) or _("Unlimited")))
+                    if parents :       
+                        print "    %s" % parents
+                else :    
+                    if options["charge"] :
+                        printer.setPrices(perpage, perjob)    
+                    if options["description"] is not None :
+                        printer.setDescription(options["description"].strip())
+                    if options["nopassthrough"] and printer.PassThrough :    
+                        self.storage.setPrinterPassThroughMode(printer, 0)
+                    if options["passthrough"] and not printer.PassThrough :    
+                        self.storage.setPrinterPassThroughMode(printer, 1)
+                    if (maxjobsize is not None) and (printer.MaxJobSize != maxjobsize) :    
+                        self.storage.setPrinterMaxJobSize(printer, maxjobsize)
+                    if options["groups"] :    
+                        for pgroup in printersgroups :
+                            if options["remove"] :
+                                pgroup.delPrinterFromGroup(printer)
+                            else :
+                                pgroup.addPrinterToGroup(printer)    
                      
 if __name__ == "__main__" : 
