Index: /pykota/trunk/bin/cupspykota
===================================================================
--- /pykota/trunk/bin/cupspykota (revision 2057)
+++ /pykota/trunk/bin/cupspykota (revision 2060)
@@ -24,4 +24,8 @@
 #
 # $Log$
+# Revision 1.87  2005/02/14 22:53:44  jalet
+# Now always precomputes the job's size with the internal PDL parser, and not
+# only when 'enforcement: strict' was set in pykota.conf
+#
 # Revision 1.86  2005/02/13 22:48:37  jalet
 # Added the md5sum to the history
@@ -378,4 +382,45 @@
         """   
         return 0
+        
+    def genBanner(self, bannerfileorcommand) :
+        """Reads a banner or generates one through an external command.
+        
+           Returns the banner's content in a format which MUST be accepted
+           by the printer.
+        """
+        if bannerfileorcommand :
+            banner = "" # no banner by default
+            if os.access(bannerfileorcommand, os.X_OK) or not os.path.isfile(bannerfileorcommand) :
+                self.logdebug("Launching %s to generate a banner." % bannerfileorcommand)
+                child = popen2.Popen3(bannerfileorcommand, capturestderr=1)
+                banner = child.fromchild.read()
+                child.tochild.close()
+                child.childerr.close()
+                child.fromchild.close()
+                status = child.wait()
+                if os.WIFEXITED(status) :
+                    status = os.WEXITSTATUS(status)
+                self.printInfo(_("Banner generator %s exit code is %s") % (bannerfileorcommand, str(status)))
+            else :
+                self.logdebug("Using %s as the banner." % bannerfileorcommand)
+                try :
+                    fh = open(bannerfileorcommand, 'r')
+                except IOError, msg :    
+                    self.printInfo("Impossible to open %s : %s" % (bannerfileorcommand, msg), "error")
+                else :    
+                    banner = fh.read()
+                    fh.close()
+            if banner :        
+                return cStringIO.StringIO(banner)
+    
+    def startingBanner(self, printername) :
+        """Retrieves a starting banner for current printer and returns its content."""
+        self.logdebug("Retrieving starting banner...")
+        return self.genBanner(self.config.getStartingBanner(printername))
+    
+    def endingBanner(self, printername) :
+        """Retrieves an ending banner for current printer and returns its content."""
+        self.logdebug("Retrieving ending banner...")
+        return self.genBanner(self.config.getEndingBanner(printername))
         
     def getCupsConfigDirectives(self, directives=[]) :
@@ -480,11 +525,8 @@
             os.environ["PYKOTAPHASE"] = "BEFORE"
             
-            # do we want strict or laxist quota enforcement ?
-            if self.config.getPrinterEnforcement(printer.Name) == "STRICT" :
-                self.softwareJobSize = self.precomputeJobSize()
-                self.softwareJobPrice = userpquota.computeJobPrice(self.softwareJobSize)
-                self.logdebug("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice))
-            os.environ["PYKOTAPRECOMPUTEDJOBSIZE"] = str(self.softwareJobSize)
+            # precomputes the job's price
+            self.softwareJobPrice = userpquota.computeJobPrice(self.softwareJobSize)
             os.environ["PYKOTAPRECOMPUTEDJOBPRICE"] = str(self.softwareJobPrice)
+            self.logdebug("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice))
             
             # if no data to pass to real backend, probably a filter
Index: /pykota/trunk/bin/lprngpykota
===================================================================
--- /pykota/trunk/bin/lprngpykota (revision 2057)
+++ /pykota/trunk/bin/lprngpykota (revision 2060)
@@ -24,4 +24,8 @@
 #
 # $Log$
+# Revision 1.15  2005/02/14 22:53:44  jalet
+# Now always precomputes the job's size with the internal PDL parser, and not
+# only when 'enforcement: strict' was set in pykota.conf
+#
 # Revision 1.14  2005/02/13 22:48:37  jalet
 # Added the md5sum to the history
@@ -137,11 +141,8 @@
         os.environ["PYKOTAPHASE"] = "BEFORE"
         
-        # do we want strict or laxist quota enforcement ?
-        if self.config.getPrinterEnforcement(printer.Name) == "STRICT" :
-            self.softwareJobSize = self.precomputeJobSize()
-            self.softwareJobPrice = userpquota.computeJobPrice(self.softwareJobSize)
-            self.logdebug("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice))
-        os.environ["PYKOTAPRECOMPUTEDJOBSIZE"] = str(self.softwareJobSize)
+        # precomputes the job's price
+        self.softwareJobPrice = userpquota.computeJobPrice(self.softwareJobSize)
         os.environ["PYKOTAPRECOMPUTEDJOBPRICE"] = str(self.softwareJobPrice)
+        self.logdebug("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice))
         
         # if no data to pass to real backend, probably a filter
@@ -251,4 +252,6 @@
             # retrieve the job size    
             jobsize = self.accounter.getJobSize(printer)
+            if self.softwareJobSize and (jobsize != self.softwareJobSize) :
+                self.printInfo(_("Beware : computed job size (%s) != precomputed job size (%s)") % (jobsize, self.softwareJobSize), "error")
             
             self.printMoreInfo(user, printer, _("Job size : %i") % jobsize)
Index: /pykota/trunk/pykota/tool.py
===================================================================
--- /pykota/trunk/pykota/tool.py (revision 2054)
+++ /pykota/trunk/pykota/tool.py (revision 2060)
@@ -22,4 +22,8 @@
 #
 # $Log$
+# Revision 1.150  2005/02/14 22:53:44  jalet
+# Now always precomputes the job's size with the internal PDL parser, and not
+# only when 'enforcement: strict' was set in pykota.conf
+#
 # Revision 1.149  2005/02/13 22:02:29  jalet
 # Big database structure changes. Upgrade script is now included as well as
@@ -1190,6 +1194,8 @@
         self.jobdatastream = self.openJobDataStream()
         self.checksum = self.computeChecksum()
+        self.softwareJobSize = self.precomputeJobSize()
+        os.environ["PYKOTAPRECOMPUTEDJOBSIZE"] = str(self.softwareJobSize)
         os.environ["PYKOTAJOBSIZEBYTES"] = str(self.jobSizeBytes)
-        self.logdebug("Job size is %s bytes" % self.jobSizeBytes)
+        self.logdebug("Job size is %s bytes on %s pages." % (self.jobSizeBytes, self.softwareJobSize))
         self.logdebug("Capturing SIGTERM events.")
         signal.signal(signal.SIGTERM, self.sigterm_handler)
@@ -1327,46 +1333,5 @@
             self.logdebug("Executing post-hook [%s]" % posthook)
             os.system(posthook)
-
-    def genBanner(self, bannerfileorcommand) :
-        """Reads a banner or generates one through an external command.
-        
-           Returns the banner's content in a format which MUST be accepted
-           by the printer.
-        """
-        if bannerfileorcommand :
-            banner = "" # no banner by default
-            if os.access(bannerfileorcommand, os.X_OK) or not os.path.isfile(bannerfileorcommand) :
-                self.logdebug("Launching %s to generate a banner." % bannerfileorcommand)
-                child = popen2.Popen3(bannerfileorcommand, capturestderr=1)
-                banner = child.fromchild.read()
-                child.tochild.close()
-                child.childerr.close()
-                child.fromchild.close()
-                status = child.wait()
-                if os.WIFEXITED(status) :
-                    status = os.WEXITSTATUS(status)
-                self.printInfo(_("Banner generator %s exit code is %s") % (bannerfileorcommand, str(status)))
-            else :
-                self.logdebug("Using %s as the banner." % bannerfileorcommand)
-                try :
-                    fh = open(bannerfileorcommand, 'r')
-                except IOError, msg :    
-                    self.printInfo("Impossible to open %s : %s" % (bannerfileorcommand, msg), "error")
-                else :    
-                    banner = fh.read()
-                    fh.close()
-            if banner :        
-                return cStringIO.StringIO(banner)
-    
-    def startingBanner(self, printername) :
-        """Retrieves a starting banner for current printer and returns its content."""
-        self.logdebug("Retrieving starting banner...")
-        return self.genBanner(self.config.getStartingBanner(printername))
-    
-    def endingBanner(self, printername) :
-        """Retrieves an ending banner for current printer and returns its content."""
-        self.logdebug("Retrieving ending banner...")
-        return self.genBanner(self.config.getEndingBanner(printername))
-        
+            
     def printInfo(self, message, level="info") :        
         """Sends a message to standard error."""
