Robovojtik/main.py
2025-03-20 01:32:29 +01:00

36 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Module: main.py
---------------
Hlavní spouštěcí skript pro Robovojtíka.
Importuje moduly pro API komunikaci, shellové funkce a uživatelské rozhraní.
"""
import argparse
import queue
import logging
import logging.handlers
import ui
def main():
parser = argparse.ArgumentParser(description="Robovojtík interaktivní shell asistent")
parser.add_argument("--log", action="store_true", help="Zapne logování do souboru robovojtik.log")
args = parser.parse_args()
listener = None
if args.log:
log_queue = queue.Queue(-1)
logger = logging.getLogger("robovojtik")
logger.setLevel(logging.DEBUG)
qh = logging.handlers.QueueHandler(log_queue)
logger.addHandler(qh)
fh = logging.FileHandler("robovojtik.log")
fh.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
listener = logging.handlers.QueueListener(log_queue, fh)
listener.start()
logger.debug("Logování zapnuto.")
ui.main_ui()
if listener:
listener.stop()
if __name__ == "__main__":
main()