This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
def save_file(name, data):
|
||||
temp_path = os.path.join(os.path.dirname(__file__), 'temp')
|
||||
@ -14,8 +15,15 @@ def remove_file(path):
|
||||
|
||||
def clear_dir():
|
||||
temp_path = os.path.join(os.path.dirname(__file__), 'temp')
|
||||
try:
|
||||
os.rmdir(temp_path)
|
||||
print('temp dir is cleared')
|
||||
except:
|
||||
print('temp clear failed')
|
||||
flag = True
|
||||
for files in os.listdir(temp_path):
|
||||
path = os.path.join(temp_path, files)
|
||||
|
||||
try:
|
||||
shutil.rmtree(path)
|
||||
except OSError:
|
||||
os.remove(path)
|
||||
|
||||
print('Info: temp dir is cleared')
|
||||
|
||||
|
Reference in New Issue
Block a user