log: Fix support of 'supybot-test --clean'

Broken in dff394df64.
This commit is contained in:
Valentin Lorentz 2021-10-18 10:08:31 +02:00
parent 63eb6672ea
commit 1f618b9773
2 changed files with 11 additions and 6 deletions

View File

@ -234,6 +234,7 @@ if __name__ == '__main__':
print('Testing began at %s (pid %s)' % (time.ctime(), os.getpid()))
if options.clean:
shutil.rmtree(conf.supybot.directories.log())
log._mkDirs()
shutil.rmtree(conf.supybot.directories.conf())
shutil.rmtree(conf.supybot.directories.data())
result = runner.run(suite)

View File

@ -176,14 +176,18 @@ class ColorizedFormatter(Formatter):
else:
return Formatter.format(self, record, *args, **kwargs)
_logDir = conf.supybot.directories.log()
if not os.path.exists(_logDir):
os.mkdir(_logDir, 0o755)
def _mkDirs():
global _logDir, pluginLogDir
_logDir = conf.supybot.directories.log()
if not os.path.exists(_logDir):
os.mkdir(_logDir, 0o755)
pluginLogDir = os.path.join(_logDir, 'plugins')
pluginLogDir = os.path.join(_logDir, 'plugins')
if not os.path.exists(pluginLogDir):
os.mkdir(pluginLogDir, 0o755)
if not os.path.exists(pluginLogDir):
os.mkdir(pluginLogDir, 0o755)
_mkDirs()
try:
messagesLogFilename = os.path.join(_logDir, 'messages.log')