Changeset 1756 for pykota/trunk
- Timestamp:
- 09/28/04 23:38:56 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/tool.py
r1725 r1756 22 22 # 23 23 # $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 # 24 28 # Revision 1.121 2004/09/15 18:47:58 jalet 25 29 # Re-Extends the list of invalid characters in names to prevent … … 456 460 import socket 457 461 import tempfile 462 import md5 458 463 import ConfigParser 459 464 … … 964 969 self.exportJobInfo() 965 970 self.jobdatastream = self.openJobDataStream() 971 self.checksum = self.computeChecksum() 966 972 os.environ["PYKOTAJOBSIZEBYTES"] = str(self.jobSizeBytes) 967 973 self.logdebug("Job size is %s bytes" % self.jobSizeBytes) … … 973 979 sys.stderr.write("%s: PyKota (PID %s) : %s\n" % (level.upper(), os.getpid(), message.strip())) 974 980 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 975 996 976 997 def openJobDataStream(self) :