Index: pykota/trunk/pykota/version.py
===================================================================
--- pykota/trunk/pykota/version.py (revision 1451)
+++ pykota/trunk/pykota/version.py (revision 1463)
@@ -22,5 +22,5 @@
 #
 
-__version__ = "1.19alpha5_unofficial"
+__version__ = "1.19alpha6_unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""
Index: pykota/trunk/bin/pkpgcounter
===================================================================
--- pykota/trunk/bin/pkpgcounter (revision 1462)
+++ pykota/trunk/bin/pkpgcounter (revision 1463)
@@ -24,4 +24,7 @@
 #
 # $Log$
+# Revision 1.9  2004/05/10 07:23:21  jalet
+# pykotme now uses pkpgcounter to compute the job's size.
+#
 # Revision 1.8  2004/05/08 15:12:23  jalet
 # Improved PCL6 support
@@ -396,5 +399,5 @@
     
 if __name__ == "__main__" :    
-    if len(sys.argv) < 2 :
+    if (len(sys.argv) < 2) or ((not sys.stdin.isatty()) and ("-" not in sys.argv[1:])) :
         sys.argv.append("-")
         
Index: pykota/trunk/bin/pykotme
===================================================================
--- pykota/trunk/bin/pykotme (revision 1285)
+++ pykota/trunk/bin/pykotme (revision 1463)
@@ -24,4 +24,7 @@
 #
 # $Log$
+# Revision 1.8  2004/05/10 07:23:21  jalet
+# pykotme now uses pkpgcounter to compute the job's size.
+#
 # Revision 1.7  2004/01/12 22:43:40  jalet
 # New formula to compute a job's price
@@ -123,58 +126,35 @@
     def main(self, files, options) :
         """Gives print quotes."""
-        if not files :
-            files = [ sys.stdin ]
+        if (not sys.stdin.isatty()) and ("-" not in files) :
+            files.append("-")
+        pipe = os.popen("pkpgcounter %s" % " ".join([' "%s"' % f for f in files]))
+        answer = pipe.readline().strip()
+        status = pipe.close()
+        try :
+            if status is None :
+                nbpages = int(answer)
+            else :        
+                raise ValueError, "ERROR in pkpgcounter" 
+        except ValueError, msg :    
+            sys.stderr.write(_("Unable to compute size of %s in number of pages.\n") % files)
+            sys.stderr.write("%s\n" % msg)
+        else :    
+            # get current user
+            uid = os.geteuid()
+            username = pwd.getpwuid(uid)[0]
+            user = self.storage.getUser(username)
+            if user.Exists and user.LimitBy and (user.LimitBy.lower() == "balance"):
+                print _("Your account balance : %.2f") % (user.AccountBalance or 0.0)
+                
+            printers = self.storage.getMatchingPrinters(options["printer"])
+            if not printers :
+                raise PyKotaToolError, _("There's no printer matching %s") % options["printer"]
+                
+            print _("Job size : %i pages") % nbpages    
+            for printer in printers :
+                userpquota = self.storage.getUserPQuota(user, printer)
+                cost = userpquota.computeJobPrice(nbpages)
+                print _("Cost on printer %s : %.2f") % (printer.Name, cost)
             
-        nbpages = 0    
-        for filename in files :
-            if filename is sys.stdin :
-                stream = filename
-            else :
-                if filename == "-" :
-                    stream = sys.stdin
-                else :    
-                    try :
-                        stream = open(filename, "rb")
-                    except IOError, msg :    
-                        sys.stderr.write("%s\n" % msg)
-                        continue
-            nb = self.getNbPages(stream)
-            if nb is None :
-                sys.stderr.write(_("Unable to compute size of %s in number of pages.\n") % filename)
-            else :
-                nbpages += nb
-            if not (filename is sys.stdin) :        
-                stream.close()
-                
-        # get current user
-        uid = os.geteuid()
-        username = pwd.getpwuid(uid)[0]
-        user = self.storage.getUser(username)
-        if user.Exists and user.LimitBy and (user.LimitBy.lower() == "balance"):
-            print _("Your account balance : %.2f") % (user.AccountBalance or 0.0)
-            
-        printers = self.storage.getMatchingPrinters(options["printer"])
-        if not printers :
-            raise PyKotaToolError, _("There's no printer matching %s") % options["printer"]
-            
-        print _("Job size : %i pages") % nbpages    
-        for printer in printers :
-            userpquota = self.storage.getUserPQuota(user, printer)
-            cost = userpquota.computeJobPrice(nbpages)
-            print _("Cost on printer %s : %.2f") % (printer.Name, cost)
-            
-    def getNbPages(self, stream) :        
-        """Tries to compute the file's size in number of pages, the best we can."""
-        nbpages = [] # in case some user wants to put several %%Pages: entries in the file
-        for line in stream.xreadlines() :
-            line = line.strip()
-            if line.startswith("%%Pages: ") :
-                try :
-                    nbpages.append(int(line[9:]))
-                except ValueError :    
-                    pass
-        if nbpages :            
-            return max(nbpages)
-        
 if __name__ == "__main__" : 
     retcode = 0
Index: pykota/trunk/NEWS
===================================================================
--- pykota/trunk/NEWS (revision 1459)
+++ pykota/trunk/NEWS (revision 1463)
@@ -22,4 +22,11 @@
 PyKota NEWS :
 
+    - 1.19alpha6 :
+    
+        - pykotme now uses pkpgcounter to compute the size of the
+          job. This modification adds PCL5 and soon PCLXL (PCL6)
+          support. You can now get quotes for PCL in addition to 
+          PostScript.
+          
     - 1.19alpha5 :
     
