mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
set logging level to info by default, and switch to debug when turned on from debug options
changed almost all of print statement to debug logs
This commit is contained in:
parent
fc3c8746c8
commit
608a8548fb
@ -36,7 +36,7 @@ def initialize(window_to_hide):
|
||||
|
||||
if new_session is None:
|
||||
logging.error("Couldn't create a session, some features might not work")
|
||||
print(f"created session {new_session}")
|
||||
logging.debug(f"created session {new_session}")
|
||||
|
||||
try:
|
||||
is_admin = os.getuid() == 0
|
||||
@ -54,6 +54,8 @@ def initialize(window_to_hide):
|
||||
|
||||
|
||||
def main():
|
||||
print("launching please wait...")
|
||||
|
||||
config.init()
|
||||
if not gui.check_eula():
|
||||
return
|
||||
@ -67,12 +69,10 @@ def main():
|
||||
finish_splash()
|
||||
update_dialog.check_update(gui_window)
|
||||
|
||||
print("launching please wait...")
|
||||
|
||||
info_logger = ["comtypes", "PIL"]
|
||||
for i in info_logger:
|
||||
pil_logger = logging.getLogger(i)
|
||||
pil_logger.setLevel(logging.INFO)
|
||||
_logger = logging.getLogger(i)
|
||||
_logger.setLevel(logging.INFO)
|
||||
|
||||
window_to_hide = win32gui.GetForegroundWindow()
|
||||
|
||||
|
@ -47,9 +47,9 @@ class WindowClient:
|
||||
return None
|
||||
|
||||
if not window_server.screen_ready():
|
||||
print("waiting for screen...")
|
||||
logging.debug("waiting for screen...")
|
||||
helper.wait_until(window_server.screen_ready)
|
||||
print("screen ready, continuing...")
|
||||
logging.debug("screen ready, continuing...")
|
||||
|
||||
temp_img = WindowServer.Screen
|
||||
|
||||
|
@ -122,13 +122,13 @@ class FullAuto(IEngine):
|
||||
if not current:
|
||||
return False
|
||||
|
||||
print(f"Moving from {(current[0], current[1])} to {target}")
|
||||
logging.debug(f"Moving from {(current[0], current[1])} to {target}")
|
||||
move_vec = target[0] - current[0], target[1] - current[1]
|
||||
|
||||
dist = math.sqrt(move_vec[0] ** 2 + move_vec[1] ** 2)
|
||||
print(f"distance: {dist}")
|
||||
logging.debug(f"distance: {dist}")
|
||||
if dist < 5e-05:
|
||||
print("distance very small skipping")
|
||||
logging.debug("distance very small skipping")
|
||||
return True
|
||||
|
||||
target_angle = math.degrees(math.atan2(-move_vec[1], move_vec[0])) + 90
|
||||
@ -138,11 +138,11 @@ class FullAuto(IEngine):
|
||||
return False
|
||||
|
||||
walking_time = dist / self.calibrator.move_factor
|
||||
print(f"walking for {walking_time}")
|
||||
logging.debug(f"walking for {walking_time}")
|
||||
kb.press('w')
|
||||
time.sleep(walking_time)
|
||||
kb.release('w')
|
||||
print("done")
|
||||
logging.debug("done")
|
||||
# todo: maybe check if it reached the destination before returning true?
|
||||
return True
|
||||
|
||||
@ -157,7 +157,7 @@ class FullAuto(IEngine):
|
||||
target_angle = 360 + target_angle
|
||||
while target_angle > 360:
|
||||
target_angle -= 360
|
||||
print(f"Rotating from {from_angle} to {target_angle}")
|
||||
logging.debug(f"Rotating from {from_angle} to {target_angle}")
|
||||
|
||||
angle_diff = target_angle - from_angle
|
||||
|
||||
@ -166,7 +166,7 @@ class FullAuto(IEngine):
|
||||
|
||||
rotate_times = int(angle_diff / self.calibrator.rot_factor) * -1
|
||||
|
||||
print(f"rotate_times: {rotate_times}")
|
||||
logging.debug(f"rotate_times: {rotate_times}")
|
||||
|
||||
for _ in range(abs(rotate_times)):
|
||||
mse.move(sign(rotate_times) * FullAuto.rotate_by * -1, 0)
|
||||
|
@ -2,6 +2,8 @@ import logging
|
||||
import typing
|
||||
from logging import StreamHandler, Formatter
|
||||
|
||||
from fishy.helper.config import config
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from . import GUI
|
||||
|
||||
@ -12,9 +14,9 @@ class GUIStreamHandler(StreamHandler):
|
||||
self.gui = gui
|
||||
|
||||
def emit(self, record):
|
||||
# todo implement verbose/debug option to show more info
|
||||
# formatter = Formatter('%(name)s - %(levelname)s - %(message)s')
|
||||
# self.setFormatter(formatter)
|
||||
formatter = Formatter('%(levelname)s - %(message)s')
|
||||
self.setFormatter(formatter)
|
||||
self.setLevel(logging.DEBUG if config.get("debug", False) else logging.INFO)
|
||||
msg = self.format(record)
|
||||
self.gui.call_in_thread(lambda: _write_to_console(self.gui, msg))
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import logging
|
||||
import time
|
||||
from multiprocessing import Process, Queue
|
||||
from threading import Thread
|
||||
@ -69,10 +70,11 @@ class HotKey:
|
||||
def start(self):
|
||||
self.process.start()
|
||||
self.event.start()
|
||||
logging.debug("hotkey process started")
|
||||
|
||||
def stop(self):
|
||||
self.inq.put("stop")
|
||||
self.outq.put("stop")
|
||||
self.process.join()
|
||||
self.event.join()
|
||||
print("hotkey process ended")
|
||||
logging.debug("hotkey process ended")
|
||||
|
Loading…
Reference in New Issue
Block a user