Index: /pykota/trunk/pykota/storage.py
===================================================================
--- /pykota/trunk/pykota/storage.py (revision 3133)
+++ /pykota/trunk/pykota/storage.py (revision 3245)
@@ -338,10 +338,10 @@
                                 totalprice += pageprice
                             else :    
-                                coefficients = self.Printer.Coefficients
+                                coefficients = upq.Printer.Coefficients
                                 for (ink, value) in usage.items() :
                                     coefvalue = coefficients.get(ink, 1.0)
                                     coefprice = (coefvalue * pageprice) / 100.0
                                     inkprice = coefprice * value
-                                    self.parent.tool.logdebug("Applying coefficient %f for color %s (used at %f%% on page %i) to base cost %f gives %f" % (coefvalue, ink, value, pageindex+1, pageprice, inkprice))
+                                    self.parent.tool.logdebug("Applying coefficient %f for color %s (used at %f%% on page %i) to base cost %f on printer %s gives %f" % (coefvalue, ink, value, pageindex+1, pageprice, upq.Printer.Name, inkprice))
                                     totalprice += inkprice
         if self.User.OverCharge != 1.0 : # TODO : beware of rounding errors
Index: /pykota/trunk/pykota/accounters/software.py
===================================================================
--- /pykota/trunk/pykota/accounters/software.py (revision 3133)
+++ /pykota/trunk/pykota/accounters/software.py (revision 3245)
@@ -66,8 +66,11 @@
                     self.filter.printInfo(_("Unable to precompute the job's size with the generic PDL analyzer : %s") % msg, "warn")
                 else :    
-                    if self.filter.InputFile is not None :
-                        # when a filename is passed as an argument, the backend 
-                        # must generate the correct number of copies.
-                        jobsize *= self.filter.Copies
+                    try :
+                        if self.filter.InputFile is not None :
+                            # when a filename is passed as an argument, the backend 
+                            # must generate the correct number of copies.
+                            jobsize *= self.filter.Copies
+                    except AttributeError : # When not run from the cupspykota backend        
+                        pass
                 infile.close()        
         return jobsize        
Index: /pykota/trunk/pykota/accounters/hardware.py
===================================================================
--- /pykota/trunk/pykota/accounters/hardware.py (revision 3162)
+++ /pykota/trunk/pykota/accounters/hardware.py (revision 3245)
@@ -31,7 +31,7 @@
 
 class Accounter(AccounterBase) :
-    def __init__(self, kotabackend, arguments, ispreaccounter=0) :
+    def __init__(self, kotabackend, arguments, ispreaccounter=0, name="hardware") :
         """Initializes querying accounter."""
-        AccounterBase.__init__(self, kotabackend, arguments)
+        AccounterBase.__init__(self, kotabackend, arguments, ispreaccounter, name)
         self.isSoftware = 0
         
Index: /pykota/trunk/pykota/accounters/ink.py
===================================================================
--- /pykota/trunk/pykota/accounters/ink.py (revision 3133)
+++ /pykota/trunk/pykota/accounters/ink.py (revision 3245)
@@ -87,9 +87,12 @@
                         self.inkUsage.append(colordict)    
                     jobsize = len(pages)
-                    if self.filter.InputFile is not None :
-                        # when a filename is passed as an argument, the backend 
-                        # must generate the correct number of copies.
-                        jobsize *= self.filter.Copies
-                        self.inkUsage *= self.filter.Copies
+                    try :
+                        if self.filter.InputFile is not None :
+                            # when a filename is passed as an argument, the backend 
+                            # must generate the correct number of copies.
+                            jobsize *= self.filter.Copies
+                            self.inkUsage *= self.filter.Copies
+                    except AttributeError : # When not run from the cupspykota backend 
+                        pass
                     self.filter.logdebug("Ink usage : %s ===> %s" % (cspace, repr(self.inkUsage)))
         return jobsize        
Index: /pykota/trunk/pykota/accounter.py
===================================================================
--- /pykota/trunk/pykota/accounter.py (revision 3184)
+++ /pykota/trunk/pykota/accounter.py (revision 3245)
@@ -40,6 +40,7 @@
 class AccounterBase :    
     """A class to account print usage by querying printers."""
-    def __init__(self, kotafilter, arguments, ispreaccounter=0) :
+    def __init__(self, kotafilter, arguments, ispreaccounter=0, name="Unknown") :
         """Sets instance vars depending on the current printer."""
+        self.name = name
         self.filter = kotafilter
         self.arguments = arguments
@@ -106,3 +107,3 @@
         raise PyKotaAccounterError, _("Unsupported accounter backend %s") % backend
     else :    
-        return accounterbackend.Accounter(kotafilter, args, ispreaccounter)
+        return accounterbackend.Accounter(kotafilter, args, ispreaccounter, backend.lower())
Index: /pykota/trunk/bin/pykotme
===================================================================
--- /pykota/trunk/bin/pykotme (revision 3133)
+++ /pykota/trunk/bin/pykotme (revision 3245)
@@ -30,6 +30,5 @@
 
 from pykota.tool import PyKotaTool, PyKotaCommandLineError, crashed, N_
-
-from pkpgpdls import analyzer, pdlparser
+from pykota.accounter import openAccounter
     
 
@@ -83,11 +82,4 @@
         if (not sys.stdin.isatty()) and ("-" not in files) :
             files.append("-")
-        totalsize = 0    
-        for filename in files :    
-            try :
-                parser = analyzer.PDLAnalyzer(filename)
-                totalsize += parser.getJobSize()
-            except (pdlparser.PDLParserError, IOError), msg :    
-                self.printInfo(msg)
             
         printers = self.storage.getMatchingPrinters(options["printer"])
@@ -100,22 +92,41 @@
             print _("Your account balance : %.2f") % (user.AccountBalance or 0.0)
             
-        print _("Job size : %i pages") % totalsize    
         if user.Exists :
+            sizeprinted = False
+            done = {}
+            for printer in printers :
+                # Now fake some values. TODO : improve API to not need this anymore    
+                self.PrinterName = printer.Name
+                self.JobSizeBytes = 1
+                self.preaccounter = openAccounter(self, ispreaccounter=1)
+                key = self.preaccounter.name + self.preaccounter.arguments
+                if not done.has_key(key) :
+                    totalsize = 0    
+                    inkusage = []
+                    for filename in files :    
+                        self.DataFile = filename
+                        self.preaccounter.beginJob(None)
+                        self.preaccounter.endJob(None)
+                        totalsize += self.preaccounter.getJobSize(None)
+                        inkusage.extend(self.preaccounter.inkUsage)
+                    done[key] = (totalsize, inkusage)    
+                (totalsize, inkusage) = done[key]    
+                if not sizeprinted :    
+                    print _("Job size : %i pages") % totalsize    
+                    sizeprinted = True
+                userpquota = self.storage.getUserPQuota(user, printer)
+                if userpquota.Exists :
+                    if printer.MaxJobSize and (totalsize > printer.MaxJobSize) :
+                        print _("You are not allowed to print so many pages on printer %s at this time.") % printer.Name
+                    else :    
+                        cost = userpquota.computeJobPrice(totalsize, inkusage)
+                        msg = _("Cost on printer %s : %.2f") % (printer.Name, cost)
+                        if printer.PassThrough :
+                            msg = "%s (%s)" % (msg, _("won't be charged, printer is in passthrough mode"))
+                        elif user.LimitBy == "nochange" :    
+                            msg = "%s (%s)" % (msg, _("won't be charged, your account is immutable"))
+                        print msg    
             if user.LimitBy == "noprint" :
                 print _("Your account settings forbid you to print at this time.")
-            else :    
-                for printer in printers :
-                    userpquota = self.storage.getUserPQuota(user, printer)
-                    if userpquota.Exists :
-                        if printer.MaxJobSize and (totalsize > printer.MaxJobSize) :
-                            print _("You are not allowed to print so many pages on printer %s at this time.") % printer.Name
-                        else :    
-                            cost = userpquota.computeJobPrice(totalsize)
-                            msg = _("Cost on printer %s : %.2f") % (printer.Name, cost)
-                            if printer.PassThrough :
-                                msg = "%s (%s)" % (msg, _("won't be charged, printer is in passthrough mode"))
-                            elif user.LimitBy == "nochange" :    
-                                msg = "%s (%s)" % (msg, _("won't be charged, your account is immutable"))
-                            print msg    
             
 if __name__ == "__main__" : 
