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())) print('Testing began at %s (pid %s)' % (time.ctime(), os.getpid()))
if options.clean: if options.clean:
shutil.rmtree(conf.supybot.directories.log()) shutil.rmtree(conf.supybot.directories.log())
log._mkDirs()
shutil.rmtree(conf.supybot.directories.conf()) shutil.rmtree(conf.supybot.directories.conf())
shutil.rmtree(conf.supybot.directories.data()) shutil.rmtree(conf.supybot.directories.data())
result = runner.run(suite) result = runner.run(suite)

View File

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