Compare commits
2 commits
31d7cc4284
...
02ffd07d72
Author | SHA1 | Date | |
---|---|---|---|
dece | 02ffd07d72 | ||
dece | 5f7f5db0ff |
|
@ -3,6 +3,8 @@ import json
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import signal
|
import signal
|
||||||
|
import sys
|
||||||
|
import traceback
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Iterable, Optional
|
from typing import Any, Iterable, Optional
|
||||||
|
|
||||||
|
@ -123,8 +125,11 @@ class Bot(irc.client.SimpleIRCClient, Logger):
|
||||||
self.start()
|
self.start()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
self.log_i("Caught keyboard interrupt.")
|
self.log_i("Caught keyboard interrupt.")
|
||||||
except Exception as exc: # Yes, I know, who are you going to call?
|
except Exception as exc:
|
||||||
self.log_c(f"Caught unhandled exception: {exc}")
|
self.log_c(f"Caught unhandled exception: {exc}")
|
||||||
|
_, _, exc_traceback = sys.exc_info()
|
||||||
|
for line in traceback.format_tb(exc_traceback):
|
||||||
|
self.log_d(line.rstrip())
|
||||||
finally:
|
finally:
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
|
|
||||||
|
|
|
@ -15,20 +15,17 @@ class TestTranslatePlugin(unittest.TestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
# No params.
|
# No params.
|
||||||
result = plugin.parse_words(["test"])
|
result = plugin.parse_words("test".split())
|
||||||
self.assertEqual(result, ("autodetect", "en", "test"))
|
self.assertEqual(result, ("autodetect", "en", "test"))
|
||||||
# Source param.
|
# Source param (alone, so wrong).
|
||||||
result = plugin.parse_words(["!from:fr", "test"])
|
result = plugin.parse_words("from fr test".split())
|
||||||
self.assertEqual(result, ("fr", "en", "test"))
|
self.assertEqual(result, ("autodetect", "en", "from fr test"))
|
||||||
# Destination param.
|
# Destination param (alone, so wrong).
|
||||||
result = plugin.parse_words(["!to:fr", "test"])
|
result = plugin.parse_words("to fr test".split())
|
||||||
self.assertEqual(result, ("autodetect", "fr", "test"))
|
self.assertEqual(result, ("autodetect", "en", "to fr test"))
|
||||||
# Both source and dest params.
|
# Both source and dest params, OK.
|
||||||
result = plugin.parse_words(["!from:it", "!to:fr", "test"])
|
result = plugin.parse_words("from it to fr test".split())
|
||||||
self.assertEqual(result, ("it", "fr", "test"))
|
self.assertEqual(result, ("it", "fr", "test"))
|
||||||
# Badly placed param.
|
# Badly placed param.
|
||||||
result = plugin.parse_words(["!from:it", "test", "!to:fr"])
|
result = plugin.parse_words("from it test to fr".split())
|
||||||
self.assertEqual(result, ("it", "en", "test !to:fr"))
|
self.assertEqual(result, ("autodetect", "en", "from it test to fr"))
|
||||||
# Unknown param.
|
|
||||||
result = plugin.parse_words(["!zzz", "test"])
|
|
||||||
self.assertEqual(result, ("autodetect", "en", "test"))
|
|
||||||
|
|
Loading…
Reference in a new issue