daca2: improved cleanup
This commit is contained in:
parent
b41ab8a4d5
commit
94f91f20e1
|
@ -31,12 +31,37 @@ def handleRemoveReadonly(func, path, exc):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def removeAllExceptResults():
|
def removeAllExceptResults():
|
||||||
filenames = glob.glob('[A-Za-z]*')
|
count = 5
|
||||||
for filename in filenames:
|
while count > 0:
|
||||||
if os.path.isdir(filename):
|
count = count - 1
|
||||||
shutil.rmtree(filename, onerror=handleRemoveReadonly)
|
|
||||||
elif filename != 'results.txt':
|
filenames = []
|
||||||
os.remove(filename)
|
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):
|
def scanarchive(fullpath):
|
||||||
|
|
Loading…
Reference in New Issue