Changeset 2783 for pykota/trunk/bin

Show
Ignore:
Timestamp:
03/05/06 09:36:47 (18 years ago)
Author:
jerome
Message:

Now outputs the average speed, so no need to do this in filldb anymore.

Location:
pykota/trunk/bin
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r2782 r2783  
    177177             
    178178        if not options["list"] : 
    179             self.display(_("Extracting datas...")) 
     179            percent = Percent(self) 
     180            percent.display(_("Extracting datas...")) 
    180181        printers = self.storage.getMatchingPrinters(options["printer"]) 
    181182        entries = getattr(self.storage, "getMatching%ss" % suffix)(",".join(names)) 
     183        if not options["list"] : 
     184            percent.setSize(len(printers) * len(entries)) 
    182185         
    183186        if options["list"] : 
     
    197200                        print 
    198201        elif options["delete"] :     
    199             percent = Percent(self, "\n%s..." % _("Deletion"), len(printers) * len(entries)) 
     202            percent.display("\n%s..." % _("Deletion")) 
    200203            getattr(self.storage, "deleteMany%sPQuotas" % suffix)(printers, entries) 
    201204            percent.display("\n") 
     
    252255            try : 
    253256                if options["add"] : 
    254                     percent = Percent(self, "\n%s...\n" % _("Creation"), len(printers) * len(entries)) 
     257                    percent.display("\n%s...\n" % _("Creation")) 
    255258                    dicnames = {} 
    256259                    for m in entries : 
     
    284287                            percent.oneMore() 
    285288                else :         
    286                     percent = Percent(self, "\n%s...\n" % _("Modification"), len(entries) * len(printers)) 
     289                    percent.display("\n%s...\n" % _("Modification")) 
    287290                    for printer in printers : 
    288291                        for entry in entries : 
     
    302305                self.storage.commitTransaction() 
    303306                             
    304         try : 
     307        if not options["list"] : 
    305308            percent.done() 
    306         except NameError :     
    307             pass 
    308309             
    309310if __name__ == "__main__" :  
  • pykota/trunk/bin/pkbcodes

    r2782 r2783  
    9797            raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command.")) 
    9898             
     99        if not options["list"] :     
     100            percent = Percent(self) 
     101             
    99102        if not options["add"] : 
    100103            if not options["list"] : 
    101                 self.display(_("Extracting datas...")) 
     104                percent.display(_("Extracting datas...")) 
    102105            if not names :      # NB : can't happen for --delete because it's catched earlier 
    103106                names = ["*"] 
     
    105108            if not billingcodes : 
    106109                raise PyKotaCommandLineError, _("There's no billingcode matching %s") % " ".join(names) 
     110            if not options["list"] :     
     111                percent.setSize(len(billingcodes)) 
    107112                         
    108113        if options["list"] : 
     
    116121                       _("credits")) 
    117122        elif options["delete"] :     
    118             percent = Percent(self, "\n%s..." % _("Deletion"), len(billingcodes)) 
     123            percent.display("\n%s..." % _("Deletion")) 
    119124            self.storage.deleteManyBillingCodes(billingcodes) 
    120125            percent.display("\n") 
     
    129134            try : 
    130135                if options["add"] :     
    131                     percent = Percent(self, "%s...\n" % _("Creation"), len(names)) 
     136                    percent.display("%s...\n" % _("Creation")) 
     137                    percent.setSize(len(names)) 
    132138                    for bname in names : 
    133139                        billingcode = StorageBillingCode(self.storage, bname) 
     
    143149                        percent.oneMore() 
    144150                else :         
    145                     percent = Percent(self, "\n%s...\n" % _("Modification"), len(billingcodes)) 
     151                    percent.display("\n%s...\n" % _("Modification")) 
    146152                    for billingcode in billingcodes : 
    147153                        self.modifyBillingCode(billingcode, reset, description) 
     
    154160                self.storage.commitTransaction() 
    155161                         
    156         try : 
     162        if not options["list"] : 
    157163            percent.done() 
    158         except NameError :     
    159             pass 
    160164                      
    161165if __name__ == "__main__" :  
  • pykota/trunk/bin/pkprinters

    r2782 r2783  
    150150            raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command.")) 
    151151             
     152        if not options["list"] :     
     153            percent = Percent(self) 
     154             
    152155        if not options["add"] : 
    153156            if not options["list"] : 
    154                 self.display(_("Extracting datas...")) 
     157                percent.display(_("Extracting datas...")) 
    155158            if not names :      # NB : can't happen for --delete because it's catched earlier 
    156159                names = ["*"] 
     
    158161            if not printers : 
    159162                raise PyKotaCommandLineError, _("There's no printer matching %s") % " ".join(names) 
     163            if not options["list"] :     
     164                percent.setSize(len(printers)) 
    160165                 
    161166        if options["list"] : 
     
    171176                print     
    172177        elif options["delete"] :     
    173             percent = Percent(self, "\n%s..." % _("Deletion"), len(printers)) 
     178            percent.display("\n%s..." % _("Deletion")) 
    174179            self.storage.deleteManyPrinters(printers) 
    175180            percent.display("\n") 
     
    217222            try : 
    218223                if options["add"] :     
    219                     percent = Percent(self, "%s...\n" % _("Creation"), len(names)) 
     224                    percent.display("%s...\n" % _("Creation")) 
     225                    percent.setSize(len(names)) 
    220226                    for pname in names : 
    221227                        if self.isValidName(pname) : 
     
    244250                        percent.oneMore() 
    245251                else :         
    246                     percent = Percent(self, "\n%s...\n" % _("Modification"), len(printers)) 
     252                    percent.display("\n%s...\n" % _("Modification")) 
    247253                    for printer in printers :         
    248254                        self.modifyPrinter(printer, charges, perpage, perjob, \ 
     
    258264                self.storage.commitTransaction() 
    259265                 
    260         try : 
     266        if not options["list"] : 
    261267            percent.done() 
    262         except NameError :     
    263             pass 
    264268                      
    265269if __name__ == "__main__" :  
  • pykota/trunk/bin/pkusers

    r2782 r2783  
    193193        suffix = (options["groups"] and "Group") or "User"         
    194194         
     195        if not options["list"] : 
     196            percent = Percent(self) 
     197             
    195198        if not options["add"] : 
    196199            if not options["list"] : 
    197                 self.display(_("Extracting datas...")) 
     200                percent.display(_("Extracting datas...")) 
    198201            if not names :      # NB : can't happen for --delete because it's catched earlier 
    199202                names = ["*"] 
     
    201204            if not entries : 
    202205                raise PyKotaCommandLineError, _("There's no %s matching %s") % (_(suffix.lower()), " ".join(names)) 
     206            if not options["list"] :     
     207                percent.setSize(len(entries)) 
    203208                 
    204209        if options["list"] : 
     
    235240                    print 
    236241        elif options["delete"] :     
    237             percent = Percent(self, "\n%s..." % _("Deletion"), len(entries)) 
     242            percent.display("\n%s..." % _("Deletion")) 
    238243            getattr(self.storage, "deleteMany%ss" % suffix)(entries) 
    239244            percent.display("\n") 
     
    287292                if options["add"] :     
    288293                    rejectunknown = self.config.getRejectUnknown()     
    289                     percent = Percent(self, "%s...\n" % _("Creation"), len(names)) 
     294                    percent.display("%s...\n" % _("Creation")) 
     295                    percent.setSize(len(names)) 
    290296                    for ename in names : 
    291297                        email = None 
     
    347353                        percent.oneMore() 
    348354                else : 
    349                     percent = Percent(self, "\n%s...\n" % _("Modification"), len(entries))  
     355                    percent.display("\n%s...\n" % _("Modification")) 
    350356                    for entry in entries : 
    351357                        if groups : 
     
    364370                self.storage.commitTransaction() 
    365371                 
    366         try : 
     372        if not options["list"] : 
    367373            percent.done() 
    368         except NameError :     
    369             pass 
    370374                      
    371375if __name__ == "__main__" :