daca2: improved cleanup
This commit is contained in:
parent
b41ab8a4d5
commit
94f91f20e1
|
@ -31,12 +31,37 @@ def handleRemoveReadonly(func, path, exc):
|
|||
raise
|
||||
|
||||
def removeAllExceptResults():
|
||||
filenames = glob.glob('[A-Za-z]*')
|
||||
for filename in filenames:
|
||||
if os.path.isdir(filename):
|
||||
shutil.rmtree(filename, onerror=handleRemoveReadonly)
|
||||
elif filename != 'results.txt':
|
||||
os.remove(filename)
|
||||
count = 5
|
||||
while count > 0:
|
||||
count = count - 1
|
||||
|
||||
filenames = []
|
||||
for g in glob.glob('[A-Za-z0-9]*'):
|
||||
filenames.append(g)
|
||||
for g in glob.glob('.[a-z]*'):
|
||||
filenames.append(g)
|
||||
|
||||
try:
|
||||
for filename in filenames:
|
||||
if os.path.isdir(filename):
|
||||
shutil.rmtree(filename, onerror=handleRemoveReadonly)
|
||||
elif filename != 'results.txt':
|
||||
os.remove(filename)
|
||||
except WindowsError, err:
|
||||
time.sleep(30)
|
||||
if count == 0:
|
||||
print('Failed to cleanup files/folders')
|
||||
print(err)
|
||||
sys.exit(1)
|
||||
continue
|
||||
except OSError, err:
|
||||
time.sleep(30)
|
||||
if count == 0:
|
||||
print('Failed to cleanup files/folders')
|
||||
print(err)
|
||||
sys.exit(1)
|
||||
continue
|
||||
count = 0
|
||||
|
||||
|
||||
def scanarchive(fullpath):
|
||||
|
|
Loading…
Reference in New Issue