Reworked logic - in progress

This commit is contained in:
2022-08-27 03:50:01 -05:00
parent efb7b108a5
commit 55515a0825
20 changed files with 1014 additions and 0 deletions

3
1.0.2/utils/__init__.py Normal file
View File

@@ -0,0 +1,3 @@
"""
Utils module
"""

56
1.0.2/utils/logger.py Normal file
View File

@@ -0,0 +1,56 @@
# Python imports
import os, logging
# Application imports
class Logger:
"""
Create a new logging object and return it.
:note:
NOSET # Don't know the actual log level of this... (defaulting or literally none?)
Log Levels (From least to most)
Type Value
CRITICAL 50
ERROR 40
WARNING 30
INFO 20
DEBUG 10
:param loggerName: Sets the name of the logger object. (Used in log lines)
:param createFile: Whether we create a log file or just pump to terminal
:return: the logging object we created
"""
def __init__(self, config_path: str, _ch_log_lvl = logging.CRITICAL, _fh_log_lvl = logging.INFO):
self._CONFIG_PATH = config_path
self.global_lvl = logging.DEBUG # Keep this at highest so that handlers can filter to their desired levels
self.ch_log_lvl = _ch_log_lvl # Prety much the only one we ever change
self.fh_log_lvl = _fh_log_lvl
def get_logger(self, loggerName: str = "NO_LOGGER_NAME_PASSED", createFile: bool = True) -> logging.Logger:
log = logging.getLogger(loggerName)
log.setLevel(self.global_lvl)
# Set our log output styles
fFormatter = logging.Formatter('[%(asctime)s] %(pathname)s:%(lineno)d %(levelname)s - %(message)s', '%m-%d %H:%M:%S')
cFormatter = logging.Formatter('%(pathname)s:%(lineno)d] %(levelname)s - %(message)s')
ch = logging.StreamHandler()
ch.setLevel(level=self.ch_log_lvl)
ch.setFormatter(cFormatter)
log.addHandler(ch)
if createFile:
folder = self._CONFIG_PATH
file = f"{folder}/application.log"
if not os.path.exists(folder):
os.mkdir(folder)
fh = logging.FileHandler(file)
fh.setLevel(level=self.fh_log_lvl)
fh.setFormatter(fFormatter)
log.addHandler(fh)
return log

View File

@@ -0,0 +1,102 @@
# Python imports
import pyautogui
# Gtk imports
# Application imports
# Let piautogui make updates as quick as it can...
pyautogui.FAILSAFE = False # If we hit corner, that's ok
pyautogui.MINIMUM_DURATION = 0
pyautogui.PAUSE = 0
class ControlMixin:
def type(self, key):
pyautogui.typewrite(key)
def enter(self, widget = None, data = None):
pyautogui.press("enter")
# def typeString(self, widget = None, data = None):
# text = self.autoTypeField.get_text()
# for char in text:
# self.do_insert(char)
#
# def insert(self, widget = None, data = None, key = None):
# if not key:
# key = widget.get_label().strip()
#
# if self.is_keypress_type(key):
# return
#
# if self.isCapsLockOn:
# key = key.upper()
#
# self.do_insert(key)
#
#
# def do_insert(self, key):
# if self.isCtrlOn or self.isShiftOn or self.isAltOn:
# self.set_hotkeys()
#
# pyautogui.typewrite(key)
#
# if self.isCtrlOn or self.isShiftOn or self.isAltOn:
# self.unset_hotkeys()
#
#
# def is_keypress_type(self, key):
# if key in ["Esc", "Tab", "Space", "Del", "Up", "Down", "Left", "Right", "PrtSc"]:
# pyautogui.press(key.lower())
# return True
#
# for i in range(1, 13):
# fkey = 'F' + str(i)
# if key == fkey:
# pyautogui.press(key.lower())
# return True
#
# return False
#
#
# def set_hotkeys(self):
# if self.isCtrlOn:
# pyautogui.keyDown('ctrl')
# if self.isShiftOn:
# pyautogui.keyDown('shiftleft')
# pyautogui.keyDown('shiftright')
# if self.isAltOn:
# pyautogui.keyDown('alt')
#
#
# def unset_hotkeys(self):
# pyautogui.keyUp('ctrl')
# pyautogui.keyUp('shiftleft')
# pyautogui.keyUp('shiftright')
# pyautogui.keyUp('alt')
#
#
# def toggleCaps(self, widget, data=None):
# self.isCapsLockOn = False if self.isCapsLockOn else True
#
# def tgglCtrl(self, widget, data=None):
# self.isCtrlOn = False if self.isCtrlOn else True
#
# def tgglShift(self, widget, data=None):
# self.isShiftOn = False if self.isShiftOn else True
#
# def tgglAlt(self, widget, data=None):
# self.isAltOn = False if self.isAltOn else True
#
#
# def enter(self, widget, data=None):
# pyautogui.press("enter")
#
#
# def backspace(self, widget, data=None):
# pyautogui.press("backspace")