Show
Ignore:
Timestamp:
02/14/05 23:53:44 (19 years ago)
Author:
jalet
Message:

Now always precomputes the job's size with the internal PDL parser, and not
only when 'enforcement: strict' was set in pykota.conf

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/tool.py

    r2054 r2060  
    2222# 
    2323# $Log$ 
     24# Revision 1.150  2005/02/14 22:53:44  jalet 
     25# Now always precomputes the job's size with the internal PDL parser, and not 
     26# only when 'enforcement: strict' was set in pykota.conf 
     27# 
    2428# Revision 1.149  2005/02/13 22:02:29  jalet 
    2529# Big database structure changes. Upgrade script is now included as well as 
     
    11901194        self.jobdatastream = self.openJobDataStream() 
    11911195        self.checksum = self.computeChecksum() 
     1196        self.softwareJobSize = self.precomputeJobSize() 
     1197        os.environ["PYKOTAPRECOMPUTEDJOBSIZE"] = str(self.softwareJobSize) 
    11921198        os.environ["PYKOTAJOBSIZEBYTES"] = str(self.jobSizeBytes) 
    1193         self.logdebug("Job size is %s bytes" % self.jobSizeBytes) 
     1199        self.logdebug("Job size is %s bytes on %s pages." % (self.jobSizeBytes, self.softwareJobSize)) 
    11941200        self.logdebug("Capturing SIGTERM events.") 
    11951201        signal.signal(signal.SIGTERM, self.sigterm_handler) 
     
    13271333            self.logdebug("Executing post-hook [%s]" % posthook) 
    13281334            os.system(posthook) 
    1329  
    1330     def genBanner(self, bannerfileorcommand) : 
    1331         """Reads a banner or generates one through an external command. 
    1332          
    1333            Returns the banner's content in a format which MUST be accepted 
    1334            by the printer. 
    1335         """ 
    1336         if bannerfileorcommand : 
    1337             banner = "" # no banner by default 
    1338             if os.access(bannerfileorcommand, os.X_OK) or not os.path.isfile(bannerfileorcommand) : 
    1339                 self.logdebug("Launching %s to generate a banner." % bannerfileorcommand) 
    1340                 child = popen2.Popen3(bannerfileorcommand, capturestderr=1) 
    1341                 banner = child.fromchild.read() 
    1342                 child.tochild.close() 
    1343                 child.childerr.close() 
    1344                 child.fromchild.close() 
    1345                 status = child.wait() 
    1346                 if os.WIFEXITED(status) : 
    1347                     status = os.WEXITSTATUS(status) 
    1348                 self.printInfo(_("Banner generator %s exit code is %s") % (bannerfileorcommand, str(status))) 
    1349             else : 
    1350                 self.logdebug("Using %s as the banner." % bannerfileorcommand) 
    1351                 try : 
    1352                     fh = open(bannerfileorcommand, 'r') 
    1353                 except IOError, msg :     
    1354                     self.printInfo("Impossible to open %s : %s" % (bannerfileorcommand, msg), "error") 
    1355                 else :     
    1356                     banner = fh.read() 
    1357                     fh.close() 
    1358             if banner :         
    1359                 return cStringIO.StringIO(banner) 
    1360      
    1361     def startingBanner(self, printername) : 
    1362         """Retrieves a starting banner for current printer and returns its content.""" 
    1363         self.logdebug("Retrieving starting banner...") 
    1364         return self.genBanner(self.config.getStartingBanner(printername)) 
    1365      
    1366     def endingBanner(self, printername) : 
    1367         """Retrieves an ending banner for current printer and returns its content.""" 
    1368         self.logdebug("Retrieving ending banner...") 
    1369         return self.genBanner(self.config.getEndingBanner(printername)) 
    1370          
     1335             
    13711336    def printInfo(self, message, level="info") :         
    13721337        """Sends a message to standard error."""