21 lines
509 B
Python
21 lines
509 B
Python
import os
|
|
|
|
def save_file(name, data):
|
|
temp_path = os.path.join(os.path.dirname(__file__), 'temp')
|
|
with open(os.path.join(temp_path, name), 'wb') as code:
|
|
code.write(data)
|
|
|
|
def remove_file(path):
|
|
if len(path) > 0:
|
|
try:
|
|
os.remove(path)
|
|
except:
|
|
pass
|
|
|
|
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') |