diff --git a/alune/adb.py b/alune/adb.py index 71a11ac..ee97aec 100644 --- a/alune/adb.py +++ b/alune/adb.py @@ -1,6 +1,7 @@ """ Module for all ADB (Android Debug Bridge) related methods. """ + import os.path import random @@ -8,9 +9,9 @@ from adb_shell.auth.keygen import keygen from adb_shell.auth.sign_pythonrsa import PythonRSASigner import cv2 +from loguru import logger import numpy from numpy import ndarray -from loguru import logger from alune.images import ClickButton from alune.images import ImageButton @@ -23,6 +24,7 @@ class ADB: Class to hold the connection to an ADB connection via TCP. USB connection is possible, but not supported at the moment. """ + def __init__(self): """ Initiates base values for the ADB instance. @@ -73,9 +75,10 @@ async def _connect_to_device(self, port: int = 5555): except OSError: self._device = None logger.warning(f"Failed to connect to ADB session with device localhost:{port}") - # Silly hack to attempt to fall back on port 5556, in case the default port was in use when their adb session started + # Silly hack to attempt to fall back on port 5556, + # in case the default port was in use when their adb session started if port == 5555: - await self._connect_to_device(self, port=(port + 1)) + await self._connect_to_device(port + 1) def is_connected(self) -> bool: """ diff --git a/alune/helpers.py b/alune/helpers.py index ee1a13c..a8377e9 100644 --- a/alune/helpers.py +++ b/alune/helpers.py @@ -1,10 +1,13 @@ -from loguru import logger +""" +Collection of helper methods. +""" + import sys -def raise_and_exit( - error: str, - exit_code: int = 1 -) -> None: +from loguru import logger + + +def raise_and_exit(error: str, exit_code: int = 1) -> None: """ Raise the given text as an error and then exit the application diff --git a/alune/images.py b/alune/images.py index 30cd8a3..bc82608 100644 --- a/alune/images.py +++ b/alune/images.py @@ -1,6 +1,7 @@ """ Module to handle anything related to images and buttons (images that result in a click) we use. """ + from dataclasses import dataclass from enum import auto from enum import StrEnum diff --git a/alune/screen.py b/alune/screen.py index 434ceb1..0ebf144 100644 --- a/alune/screen.py +++ b/alune/screen.py @@ -1,6 +1,7 @@ """ Module for image recognition on the screen. """ + from dataclasses import dataclass import cv2 diff --git a/main.py b/main.py index cf42bee..9eef813 100644 --- a/main.py +++ b/main.py @@ -6,7 +6,6 @@ from enum import auto from enum import StrEnum from random import Random -import sys from adb_shell.exceptions import TcpTimeoutException from loguru import logger @@ -25,6 +24,7 @@ class GameState(StrEnum): """ State the game or app is in. """ + LOADING = auto() MAIN_MENU = auto() CHOOSE_MODE = auto()