Skip to content

Commit

Permalink
Fix merge causing rollback of modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
fe-art committed Sep 13, 2024
1 parent 8c56c03 commit 3bf4384
Showing 1 changed file with 15 additions and 32 deletions.
47 changes: 15 additions & 32 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from datetime import datetime
import signal
import sys
import threading
import time

from loguru import logger
from PyQt6.QtWidgets import QApplication

from clashroyalebuildabot.actions import ArchersAction
from clashroyalebuildabot.actions import BabyDragonAction
Expand All @@ -14,31 +12,14 @@
from clashroyalebuildabot.actions import MinipekkaAction
from clashroyalebuildabot.actions import MusketeerAction
from clashroyalebuildabot.actions import WitchAction
from clashroyalebuildabot.bot import Bot

start_time = datetime.now()

logger.remove()
logger.add(
sys.stderr,
format="{time} {level} {message}",
backtrace=False,
diagnose=False,
)


def update_terminal_title():
while True:
elapsed_time = datetime.now() - start_time
hours, remainder = divmod(elapsed_time.total_seconds(), 3600)
minutes, seconds = divmod(remainder, 60)
formatted_time = f"{int(hours):02}:{int(minutes):02}:{int(seconds):02}"
sys.stdout.write(f"\x1b]2;{formatted_time} | BuildABot\x07")
sys.stdout.flush()
time.sleep(1)
from clashroyalebuildabot.gui.main_window import MainWindow
from clashroyalebuildabot.gui.utils import load_config
from clashroyalebuildabot.utils.git_utils import check_and_pull_updates
from clashroyalebuildabot.utils.logger import setup_logger


def main():
check_and_pull_updates()
actions = [
ArchersAction,
GoblinBarrelAction,
Expand All @@ -50,17 +31,19 @@ def main():
WitchAction,
]
try:
bot = Bot(actions=actions)
bot.run()
config = load_config()

app = QApplication(sys.argv)
window = MainWindow(config, actions)
setup_logger(window, config)

window.show()
sys.exit(app.exec())
except Exception as e:
logger.error(f"An error occurred: {e}")
logger.error(f"An error occurred in main loop: {e}")
sys.exit(1)


if __name__ == "__main__":
signal.signal(signal.SIGINT, signal.SIG_DFL)

title_thread = threading.Thread(target=update_terminal_title, daemon=True)
title_thread.start()

main()

0 comments on commit 3bf4384

Please sign in to comment.