upgrade to python3;add some validator examples
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys, string, hashlib, os
|
||||
from stat import *
|
||||
@@ -9,9 +9,9 @@ def check_file(name, size, md5sum):
|
||||
m = hashlib.md5()
|
||||
if os.path.isfile(name):
|
||||
s = os.stat(name)[ST_SIZE]
|
||||
if s == string.atoi(size):
|
||||
if s == int(size):
|
||||
f = open(name, 'rb')
|
||||
m.update(f.read(string.atoi(size)))
|
||||
m.update(f.read(int(size)))
|
||||
f.close()
|
||||
d = m.hexdigest()
|
||||
result.write("%s %d %s\n" % (name, s, d))
|
||||
@@ -26,9 +26,10 @@ if __name__ == '__main__':
|
||||
result = open(sys.argv[3], 'w+')
|
||||
fstdout = open(sys.argv[2], 'r')
|
||||
for line in fstdout:
|
||||
name, size, md5sum = string.split(string.strip(line), ' ')
|
||||
name, size, md5sum = line.strip().split(' ')
|
||||
if not check_file(name, size, md5sum):
|
||||
print 'WA'; break
|
||||
print('WA')
|
||||
break
|
||||
fstdout.close()
|
||||
result.close()
|
||||
print 'AC'
|
||||
print('AC')
|
||||
|
||||
Reference in New Issue
Block a user