Changeset 3095 for pykota/trunk/bin

Show
Ignore:
Timestamp:
11/30/06 23:41:00 (18 years ago)
Author:
jerome
Message:

Now pkrefund displays progression percent when extracting datas too.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkrefund

    r3089 r3095  
    293293            raise PyKotaCommandLineError, _("Refunding for no reason is forbidden. Please use the --reason command line option.") 
    294294             
    295         if options["output"] : 
    296             options["output"] = options["output"].strip() 
    297             if options["output"] == "-" : 
     295        outfname = options["output"] 
     296        if outfname : 
     297            outfname = outfname.strip() 
     298            if outfname == "-" : 
    298299                options["force"] = True 
    299300                self.printInfo(_("The PDF file containing the receipts will be sent to stdout. --force is assumed."), "warn") 
     
    323324                else :     
    324325                    extractonly.update({ filterkey : filtervalue }) 
     326             
     327        percent = Percent(self) 
     328        if outfname != "-" : 
     329            percent.display("%s..." % _("Extracting datas")) 
    325330             
    326331        username = extractonly.get("username")     
     
    353358        nbcredits = 0.0 
    354359        reason = (options.get("reason") or "").strip() 
     360        percent.setSize(len(jobs)) 
     361        if outfname != "-" : 
     362            percent.display("\n") 
    355363        for job in jobs :                                     
    356364            if job.JobSize and (job.JobAction not in ("DENY", "CANCEL", "REFUND")) : 
     
    364372                    counters["nbjobs"] += 1 
    365373                    nbjobs += 1 
     374                    if outfname != "-" : 
     375                        percent.oneMore() 
    366376                else :     
    367377                    print _("Date : %s") % str(job.JobDate)[:19] 
     
    389399                            break 
    390400                    print         
    391         self.genReceipts(peruser, options["logo"].strip(), options["output"], firstnumber, reason, options["unit"]) 
    392         if options["output"] != "-" :     
     401        if outfname != "-" : 
     402            percent.done() 
     403        self.genReceipts(peruser, options["logo"].strip(), outfname, firstnumber, reason, options["unit"]) 
     404        if outfname != "-" :     
    393405            print _("Refunded %i users for %i jobs, %i pages and %.3f credits") % (len(peruser), nbjobs, nbpages, nbcredits) 
    394406