daca2: changed removeLargeFiles and removeAllExceptResults. hopefully these will handle problems better. And hopefully the problems will be logged better.

This commit is contained in:
Daniel Marjamäki 2016-08-21 11:54:08 +02:00
parent e0838ff194
commit fd6b18f759
1 changed files with 35 additions and 31 deletions

View File

@ -73,37 +73,35 @@ def handleRemoveReadonly(func, path, exc):
def removeAllExceptResults(): def removeAllExceptResults():
count = 5 filenames = []
while count > 0: for g in glob.glob('[A-Za-z0-9]*'):
count = count - 1 filenames.append(g)
for g in glob.glob('.[a-z]*'):
filenames.append(g)
filenames = [] for filename in filenames:
for g in glob.glob('[A-Za-z0-9]*'): count = 5
filenames.append(g) while count > 0:
for g in glob.glob('.[a-z]*'): count = count - 1
filenames.append(g)
try: try:
for filename in filenames:
if os.path.isdir(filename): if os.path.isdir(filename):
shutil.rmtree(filename, onerror=handleRemoveReadonly) shutil.rmtree(filename, onerror=handleRemoveReadonly)
elif filename != 'results.txt': elif filename != 'results.txt':
os.remove(filename) os.remove(filename)
except WindowsError as err: break
time.sleep(30) except WindowsError as err:
if count == 0: time.sleep(30)
print('Failed to cleanup files/folders') if count == 0:
print(err) f = open('results.txt','at')
sys.exit(1) f.write('Failed to cleanup ' + filename + ': ' + str(err))
continue f.close()
except OSError as err: except OSError as err:
time.sleep(30) time.sleep(30)
if count == 0: if count == 0:
print('Failed to cleanup files/folders') f = open('results.txt','at')
print(err) f.write('Failed to cleanup ' + filename + ': ' + str(err))
sys.exit(1) f.close()
continue
count = 0
def removeLargeFiles(path): def removeLargeFiles(path):
@ -113,14 +111,20 @@ def removeLargeFiles(path):
if os.path.islink(g): if os.path.islink(g):
continue continue
if os.path.isdir(g): if os.path.isdir(g):
removeLargeFiles(g + '/') # Remove test code
if g.endswith('/testsuite') or g.endswith('/clang/INPUTS'):
shutil.rmtree(g, onerror=handleRemoveReadonly)
else:
removeLargeFiles(g + '/')
elif os.path.isfile(g) and g[-4:] != '.txt': elif os.path.isfile(g) and g[-4:] != '.txt':
statinfo = os.stat(g) statinfo = os.stat(g)
# Remove gcc torture tests, that is not meant to be valid code if statinfo.st_size > 1000000:
if path.find('/gcc/testsuite/') > 0: try:
os.remove(g) os.remove(g)
if path.find('/clang/INPUTS/') > 0 or statinfo.st_size > 1000000: except OSError as err:
os.remove(g) f = open('results.txt','at')
f.write('Failed to remove ' + g + ': ' + str(err))
f.close()
def strfCurrTime(fmt): def strfCurrTime(fmt):
return datetime.time.strftime(datetime.datetime.now().time(), fmt) return datetime.time.strftime(datetime.datetime.now().time(), fmt)