tuxbot-bot/tuxbot/__main__.py

33 lines
709 B
Python
Raw Permalink Normal View History

2020-06-04 19:16:51 +02:00
from typing import NoReturn
2020-06-03 19:41:30 +02:00
2020-08-28 01:06:57 +02:00
from rich.console import Console
from rich.traceback import install
2020-09-02 00:08:06 +02:00
from tuxbot import ExitCodes
2020-08-28 01:06:57 +02:00
console = Console()
install(console=console)
2020-06-03 19:41:30 +02:00
2020-06-04 00:46:53 +02:00
def main() -> NoReturn:
2020-06-03 19:41:30 +02:00
try:
from .__run__ import run # pylint: disable=import-outside-toplevel
2020-06-03 19:41:30 +02:00
2020-09-02 00:08:06 +02:00
run()
2020-06-03 19:41:30 +02:00
except SystemExit as exc:
2020-09-02 00:08:06 +02:00
if exc.code == ExitCodes.RESTART:
# reimport to load changes
from .__run__ import run # pylint: disable=import-outside-toplevel
2020-09-02 00:08:06 +02:00
run()
else:
raise exc
except Exception:
console.print_exception()
2020-06-03 19:41:30 +02:00
if __name__ == "__main__":
2020-08-28 01:06:57 +02:00
try:
main()
except Exception:
console.print_exception()