Spaces:
Runtime error
Runtime error
import os, random | |
from logging import getLogger, StreamHandler, DEBUG | |
logger = getLogger(__name__) | |
handler = StreamHandler(); handler.setLevel(DEBUG) | |
logger.setLevel(DEBUG) | |
logger.addHandler(handler) | |
logger.propagate = False | |
def get_random_name(): | |
famous_painters = [ | |
"Leonardo", "DaVinci", | |
"Michelangelo", | |
"Pablo", "Picasso", | |
"Vincent", "VanGogh", | |
"Rembrandt", "VanRijn", | |
"Claude", "Monet", | |
"Salvador", "Dali", | |
"Jackson", "Pollock", | |
"Andy", "Warhol", | |
"Henri", "Matisse", | |
"Georgia", "Keeffe", | |
"Edvard", "Munch", | |
"Wassily", "Kandinsky", | |
"Gustav", "Klimt", | |
"Rene", "Magritte", | |
"Frida", "Kahlo", | |
"Edgar", "Degas", | |
"Johannes", "Vermeer", | |
"Paul", "Cezanne", | |
"Marc", "Chagall", | |
] | |
random_painter = random.choice(famous_painters) | |
# 4桁の乱数を生成 | |
rand_num = random.randint(1000, 9999) | |
return random_painter+str(rand_num) | |
def complete(work_dir): | |
work_dir = work_dir | |
# logger.debug(f"complete :", work_dir) | |
return work_dir | |
def clean(text_output): | |
# logger.debug(f"text_output : {text_output}") | |
if text_output!="idle_state": | |
logger.info(f"clean up : {text_output}.zip") | |
os.remove(f"{text_output}.zip") | |
return "idle_state" | |
else: | |
logger.info(f"reset") | |
return "idle_state" | |
def clean_by_name(text_output): | |
# logger.debug(f"text_output : {text_output}") | |
if text_output!="idle_state": | |
text_output, dir_name = text_output.split("+") | |
logger.info(f"clean up : {dir_name}.zip") | |
os.remove(f"{dir_name}.zip") | |
return "idle_state" | |
else: | |
logger.info(f"reset") | |
return "idle_state" | |