changing db folder to data

This commit is contained in:
phixxy 2024-01-20 00:34:54 -08:00
parent 040e0e72fc
commit 31962d33c6
2 changed files with 10 additions and 14 deletions

View file

@ -16,7 +16,7 @@ class StableDiffusion(commands.Cog):
self.bot = bot
self.stable_diffusion_url = os.getenv("stablediffusion_url") # Change this to stable_diffusion_url
self.working_dir = "tmp/stable_diffusion/"
self.db_dir = "db/stable_diffusion/"
self.data_dir = "data/stable_diffusion/"
self.folder_setup()
def folder_setup(self):
@ -25,8 +25,8 @@ class StableDiffusion(commands.Cog):
os.mkdir(self.working_dir)
os.mkdir(f"{self.working_dir}sfw")
os.mkdir(f"{self.working_dir}nsfw")
if not os.path.exists(self.db_dir):
os.mkdir(self.db_dir)
if not os.path.exists(self.data_dir):
os.mkdir(self.data_dir)
except:
print("StableDiffusion failed to make directories")
@ -52,7 +52,7 @@ class StableDiffusion(commands.Cog):
print(error)
current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
log_line = current_time + ': ' + str(error) + '\n'
file_name = self.db_dir + "error_log.log"
file_name = self.data_dir + "error_log.log"
with open(file_name, 'a') as f:
f.write(log_line)
return error
@ -211,11 +211,11 @@ class StableDiffusion(commands.Cog):
if prompt == None:
prompt = await self.generate_prompt()
try:
neg_prompt_file = f"{self.db_dir}negative_prompt.txt"
neg_prompt_file = f"{self.data_dir}negative_prompt.txt"
with open(neg_prompt_file, 'r') as f:
negative_prompt = f.readline()
except:
neg_prompt_file = f"{self.db_dir}negative_prompt.txt"
neg_prompt_file = f"{self.data_dir}negative_prompt.txt"
with open(neg_prompt_file, 'w') as f:
f.writelines("")
negative_prompt = ""
@ -264,7 +264,7 @@ class StableDiffusion(commands.Cog):
f = discord.File(fh, filename=my_filename)
log_data = f'Author: {ctx.author.name}, Prompt: {prompt}, Filename: {my_filename}\n'
with open(f"{self.db_dir}stable_diffusion.log", 'a') as log_file:
with open(f"{self.data_dir}stable_diffusion.log", 'a') as log_file:
log_file.writelines(log_data)
await ctx.send(f'Generated by: {ctx.author.name}\nPrompt: {prompt}', file=f)
@ -395,7 +395,7 @@ class StableDiffusion(commands.Cog):
message = ' '.join(args)
if not message:
message = "easynegative, badhandv4, verybadimagenegative_v1.3"
neg_prompt_file = f"{self.db_dir}negative_prompt.txt"
neg_prompt_file = f"{self.data_dir}negative_prompt.txt"
with open(neg_prompt_file, 'w') as f:
f.writelines(message)
await ctx.send("Changed negative prompt to " + message)