pep8 cleanup

This commit is contained in:
Adam Saudagar 2022-02-03 05:29:10 +05:30
parent 76e17c4502
commit 2893465571
15 changed files with 26 additions and 53 deletions

View File

@ -1,15 +1,12 @@
import logging
import traceback
import typing
from threading import Thread
from typing import Callable
import cv2
from playsound import playsound
from fishy.engine.common.window import WindowClient
from fishy.gui.funcs import GUIFuncsMock
from fishy.helper import helper
from fishy.helper.helper import print_exc
if typing.TYPE_CHECKING:
@ -23,7 +20,7 @@ class IEngine:
# 0 - off, 1 - running, 2 - quitting
self.state = 0
self.window = None
self.thread: Thread = None
self.thread = None
@property
def gui(self):

View File

@ -1,13 +1,7 @@
import logging
import os
from datetime import datetime
import cv2
import numpy as np
from pyzbar.pyzbar import decode, ZBarSymbol
from fishy.helper.helper import get_documents
def image_pre_process(img):
scale_percent = 100 # percent of original size

View File

@ -89,7 +89,7 @@ class WindowClient:
def show(self, to_show, resize=None, func=None):
"""
Displays the processed image for debugging purposes
:param ready_img: send ready image, just show the `ready_img` directly
:param to_show: false to destroy the window
:param resize: scale the image to make small images more visible
:param func: function to process the image
"""

View File

@ -1,17 +1,14 @@
import logging
import math
import traceback
from enum import Enum
from threading import Thread
import cv2
import d3dshot
import pywintypes
import win32api
import win32gui
from ctypes import windll
from fishy.helper.config import config
from fishy.helper.helper import print_exc
@ -38,6 +35,7 @@ def init():
Executed once before the main loop,
Finds the game window, and calculates the offset to remove the title bar
"""
# noinspection PyUnresolvedReferences
try:
WindowServer.hwnd = win32gui.FindWindow(None, "Elder Scrolls Online")

View File

@ -4,6 +4,8 @@ from pynput.keyboard import Key
from fishy.helper import hotkey
# todo: unused code remove it
def get_controls(controls: 'Controls'):
controls = [

View File

@ -1,10 +1,8 @@
import logging
import math
import time
import traceback
from threading import Thread
import cv2
from pynput import keyboard, mouse
from fishy.engine import SemiFisherEngine
@ -16,9 +14,8 @@ from fishy.engine.fullautofisher.mode.player import Player
from fishy.engine.fullautofisher.mode.recorder import Recorder
from fishy.engine.common.qr_detection import (get_qr_location,
get_values_from_image, image_pre_process)
from fishy.engine.semifisher import fishing_event, fishing_mode
from fishy.engine.semifisher import fishing_mode
from fishy.engine.semifisher.fishing_mode import FishingMode
from fishy.helper import hotkey
from fishy.helper.config import config
from fishy.helper.helper import wait_until, is_eso_active, sign, print_exc
@ -201,8 +198,6 @@ class FullAuto(IEngine):
if __name__ == '__main__':
logging.getLogger("").setLevel(logging.DEBUG)
hotkey.initalize()
# noinspection PyTypeChecker
bot = FullAuto(None)
bot.toggle_start()

View File

@ -1,6 +1,5 @@
import logging
import time
import traceback
import typing
from threading import Thread
from typing import Callable, Optional

View File

@ -2,21 +2,16 @@ import logging
import os
import tkinter as tk
import tkinter.ttk as ttk
import typing
from tkinter.filedialog import askopenfilename
from fishy.engine.common.event_handler import IEngineHandler
from fishy.engine.fullautofisher.mode.imode import FullAutoMode
from fishy.helper import helper
from fishy import web
from fishy.helper import helper
from fishy.helper.config import config
from fishy.helper.popup import PopUp
if typing.TYPE_CHECKING:
from fishy.gui import GUI
def start_fullfisher_config(gui: 'GUI'):
top = PopUp(helper.empty_function, gui._root, background=gui._root["background"])

View File

@ -26,6 +26,7 @@ def discord_login(gui: 'GUI'):
top.destroy()
top_running[0] = False
# noinspection PyUnresolvedReferences
def check():
code = int(login_code.get()) if login_code.get().isdigit() else 0
if web.login(config.get("uid"), code):

View File

@ -1,4 +1,3 @@
import logging
import queue
import threading
import tkinter as tk
@ -15,7 +14,6 @@ from fishy.gui.funcs import GUIFuncs
from ..helper.config import config
from ..helper.helper import wait_until
from . import main_gui
from .log_config import GuiLogger
@dataclass

View File

@ -10,7 +10,7 @@ from ttkthemes import ThemedTk
from fishy import helper
from fishy.web import web
from ..constants import chalutier, lam2, fishyqr
from ..constants import fishyqr
from ..helper.config import config
from .discord_login import discord_login
from ..helper.hotkey.hotkey_process import hotkey
@ -131,7 +131,7 @@ def _create(gui: 'GUI'):
hotkey.hook(Key.F9, gui.funcs.start_engine)
# noinspection PyProtectedMember
# noinspection PyProtectedMember,PyUnresolvedReferences
def set_destroy():
if gui._bot_running:
if not tk.messagebox.askyesno(title="Quit?", message="Bot engine running. Quit Anyway?"):

View File

@ -38,29 +38,29 @@ def _normalize_version(v):
return rv
def _get_highest_version(index, pkg):
def _get_highest_version(_index, _pkg):
"""
Crawls web for latest version name then returns latest version
:param index: website to check
:param pkg: package name
:param _index: website to check
:param _pkg: package name
:return: latest version normalized
"""
url = "{}/{}/".format(index, pkg)
url = "{}/{}/".format(_index, _pkg)
html = urllib.request.urlopen(url)
if html.getcode() != 200:
raise Exception # not found
soup = BeautifulSoup(html.read(), "html.parser")
versions = []
_versions = []
for link in soup.find_all('a'):
text = link.get_text()
try:
version = re.search(pkg + r'-(.*)\.tar\.gz', text).group(1)
versions.append(_normalize_version(version))
version = re.search(_pkg + r'-(.*)\.tar\.gz', text).group(1)
_versions.append(_normalize_version(version))
except AttributeError:
pass
if len(versions) == 0:
if len(_versions) == 0:
raise Exception # no version
return max(versions)
return max(_versions)
def _get_current_version():

View File

@ -15,14 +15,12 @@ from zipfile import ZipFile
import requests
import winshell
from fishy.gui import update_dialog
from playsound import playsound
from win32com.client import Dispatch
from win32comext.shell import shell, shellcon
from win32gui import GetForegroundWindow, GetWindowText
import fishy
from fishy import web
from fishy.constants import libgps, lam2, fishyqr
from fishy.helper.config import config
@ -129,8 +127,8 @@ def create_shortcut(anti_ghosting: bool):
desktop = winshell.desktop()
path = os.path.join(desktop, "Fishybot ESO.lnk")
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
_shell = Dispatch('WScript.Shell')
shortcut = _shell.CreateShortCut(path)
if anti_ghosting:
shortcut.TargetPath = r"C:\Windows\System32\cmd.exe"
@ -170,6 +168,7 @@ def addon_exists(name, url=None, v=None):
def get_addonversion(name, url=None, v=None):
if addon_exists(name):
txt = name + ".txt"
# noinspection PyBroadException
try:
with open(os.path.join(get_addondir(), name, txt)) as f:
for line in f:
@ -241,9 +240,9 @@ def _get_id(thread):
# returns id of the respective thread
if hasattr(thread, '_thread_id'):
return thread._thread_id
for id, thread in threading._active.items():
for _id, thread in threading._active.items():
if thread is thread:
return id
return _id
def kill_thread(thread):

View File

@ -2,8 +2,7 @@ import logging
from fishy.helper.auto_update import _normalize_version
from fishy.constants import chalutier, version
from fishy.helper import helper
from fishy.constants import version
from .config import config

View File

@ -4,8 +4,6 @@ import requests
from whatsmyip.ip import get_ip
from whatsmyip.providers import GoogleDnsProvider
from fishy import helper
from ..constants import apiversion
from ..helper.config import config
from . import urls
@ -88,8 +86,6 @@ def sub():
@fallback((False, False))
def is_subbed():
"""
:param uid:
:param lazy:
:return: Tuple[is_subbed, success]
"""
@ -102,8 +98,8 @@ def is_subbed():
if response.status_code != 200:
return False, False
is_subbed = response.json()["subbed"]
return is_subbed, True
_is_subbed = response.json()["subbed"]
return _is_subbed, True
@fallback(None)