Show
Ignore:
Timestamp:
09/28/04 23:38:56 (20 years ago)
Author:
jalet
Message:

Now computes the job's datas MD5 checksum to later forbid duplicate print jobs.
The checksum is not yet saved into the database.

Files:
1 modified

Legend:

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

    r1725 r1756  
    2222# 
    2323# $Log$ 
     24# Revision 1.122  2004/09/28 21:38:56  jalet 
     25# Now computes the job's datas MD5 checksum to later forbid duplicate print jobs. 
     26# The checksum is not yet saved into the database. 
     27# 
    2428# Revision 1.121  2004/09/15 18:47:58  jalet 
    2529# Re-Extends the list of invalid characters in names to prevent 
     
    456460import socket 
    457461import tempfile 
     462import md5 
    458463import ConfigParser 
    459464 
     
    964969        self.exportJobInfo() 
    965970        self.jobdatastream = self.openJobDataStream() 
     971        self.checksum = self.computeChecksum() 
    966972        os.environ["PYKOTAJOBSIZEBYTES"] = str(self.jobSizeBytes) 
    967973        self.logdebug("Job size is %s bytes" % self.jobSizeBytes) 
     
    973979        sys.stderr.write("%s: PyKota (PID %s) : %s\n" % (level.upper(), os.getpid(), message.strip())) 
    974980        sys.stderr.flush() 
     981         
     982    def computeChecksum(self) :     
     983        """Computes the MD5 checksum of the job's datas, to be able to detect and forbid duplicate jobs.""" 
     984        self.logdebug("Computing MD5 checksum for job %s" % self.jobid) 
     985        MEGABYTE = 1024*1024 
     986        checksum = md5.new() 
     987        while 1 : 
     988            data = self.jobdatastream.read(MEGABYTE)  
     989            if not data : 
     990                break 
     991            checksum.update(data)     
     992        self.jobdatastream.seek(0) 
     993        digest = checksum.hexdigest() 
     994        self.logdebug("MD5 checksum for job %s is %s" % (self.jobid, digest)) 
     995        return digest 
    975996         
    976997    def openJobDataStream(self) :