Spaces:
Running
Running
File size: 1,357 Bytes
c5d2a9e dc8f793 c5d2a9e dc8f793 c5d2a9e dc8f793 9f3f97f 7cee42d 9f3f97f dc8f793 9f3f97f dc8f793 9f3f97f c5d2a9e dc8f793 c5d2a9e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import sys
import os
import time
import threading
import shutil
import logging
now_dir = os.getcwd()
sys.path.append(now_dir)
logging.basicConfig(level=logging.DEBUG)
def infinite_loop():
while True:
try:
models_folder = os.path.join(now_dir, "logs")
for element in os.listdir(models_folder):
element_route = os.path.join(models_folder, element)
if os.path.isdir(element_route) and element != "mute":
shutil.rmtree(element_route)
elif os.path.isfile(element_route):
os.remove(element_route)
except Exception as e:
logging.error(f"Error in models_folder loop: {e}")
try:
audios_folder = os.path.join(now_dir, "audios")
for element in os.listdir(audios_folder):
element_route = os.path.join(audios_folder, element)
if os.path.isfile(element_route):
os.remove(element_route)
except Exception as e:
logging.error(f"Error in audios_folder loop: {e}")
wait_time = 24 * 60 * 60
logging.info(f"Sleeping for {wait_time} seconds")
time.sleep(wait_time)
def start_infinite_loop():
hilo_bucle = threading.Thread(target=infinite_loop)
hilo_bucle.daemon = True
hilo_bucle.start() |