output path is overwritten

This commit is contained in:
manetta 2021-02-17 16:47:52 +01:00
parent 6918715868
commit 17d71674ae

View File

@ -22,7 +22,7 @@ def del_from_db(self, message, key):
def write_log(self, message): def write_log(self, message):
template = jinja2.Template(open('template.html').read()) template = jinja2.Template(open('template.html').read())
log_path = os.path.join(self.output, message.room, 'index.html') log_path = os.path.join(output, message.room, 'index.html')
with open(log_path,'w') as out: with open(log_path,'w') as out:
html = template.render(title=self.db[message.room]['title'], db=self.db[message.room]['messages']) html = template.render(title=self.db[message.room]['title'], db=self.db[message.room]['messages'])
out.write(html) out.write(html)
@ -97,7 +97,7 @@ logbot @uptime: To check how long @logbot has been around
for room in self.rooms: for room in self.rooms:
roomname = str(re.match(r'.*@', room).group()).replace('@','') roomname = str(re.match(r'.*@', room).group()).replace('@','')
self.output = os.path.join(self.output, roomname) output = os.path.join(self.output, roomname)
# Check if the room is in the database already # Check if the room is in the database already
if not room in self.db.keys(): if not room in self.db.keys():
@ -107,13 +107,13 @@ logbot @uptime: To check how long @logbot has been around
print('INFO ', f'Added to the database: { room }') print('INFO ', f'Added to the database: { room }')
# Check if the room has an output folder already # Check if the room has an output folder already
if not os.path.exists(self.output): if not os.path.exists(output):
os.mkdir(self.output) os.mkdir(output)
shutil.copy('stylesheet.css', self.output) shutil.copy('stylesheet.css', output)
print('INFO ', f'Created a folder for: { room }') print('INFO ', f'Created a folder for: { room }')
print('INFO ', f'Copied stylesheet.css to: { room }') print('INFO ', f'Copied stylesheet.css to: { room }')
print('INFO ', f'Output folder is set to: { self.output }') print('INFO ', f'Output folder is set to: { output }')
def group(self, message): def group(self, message):