diff --git a/config.cfg b/config.cfg index a3ec089..4a2fe91 100644 --- a/config.cfg +++ b/config.cfg @@ -2,10 +2,11 @@ NoBindText = No Bind [Logging] -EnableLogging = 1 -# 1 = Minimum, 3 = Full Debug -LogLevel = 3 -[BROWSER] -OpenTemplatesInBrowser = 0 -ChromePath = C:\Program Files (x86)\Google\Chrome\Application\chrome.exe \ No newline at end of file +# Log level sets the amount of logs generated for Joystick Diagrams. Default is INFO. +# INFO +# WARNING +# ERROR +# CRITICAL +# DEBUG +LogLevel=INFO \ No newline at end of file diff --git a/joystick_diagrams/__main__.py b/joystick_diagrams/__main__.py index e4a6e6e..f9ff7dc 100644 --- a/joystick_diagrams/__main__.py +++ b/joystick_diagrams/__main__.py @@ -3,12 +3,13 @@ import logging from pathlib import Path from PyQt5 import QtWidgets, QtGui, QtCore -from joystick_diagrams import config, version, manager +from joystick_diagrams import config from joystick_diagrams.ui import ui from joystick_diagrams.adaptors.dcs_world import DCSWorldParser from joystick_diagrams.adaptors.joystick_gremlin import JoystickGremlin from joystick_diagrams.adaptors.star_citizen import StarCitizen from joystick_diagrams.classes import export +from joystick_diagrams.classes.version import version _logger = logging.getLogger(__name__) @@ -59,7 +60,7 @@ def set_version(self) -> None: """ Set version in UI window """ - version_text = version.VERSION + version_text = version.get_current_version() self.label_9.setText(version_text) self.setWindowTitle("Joystick Diagrams - V" + version_text) @@ -298,17 +299,11 @@ def setup_logging() -> None: ) -def get_log_level() -> str: - """ - Returns log level as specified in config filpipe - """ - if config.debugLevel == 1: - return "WARNING" - if config.debugLevel == 2: - return "ERROR" - if config.debugLevel == 3: - return "DEBUG" - return "ERROR" +def get_log_level(): + try: + return logging.getLevelNamesMapping()[config.debugLevel] + except KeyError: + return logging.getLevelNamesMapping()["INFO"] if __name__ == "__main__": @@ -319,6 +314,6 @@ def get_log_level() -> str: window = MainWindow() window.show() app.exec() - manager.ParserPluginManager() + # manager.ParserPluginManager() except Exception as error: # pylint: disable=broad-except _logger.exception(error) diff --git a/joystick_diagrams/classes/version/version.py b/joystick_diagrams/classes/version/version.py index 8fd94f2..c57d710 100644 --- a/joystick_diagrams/classes/version/version.py +++ b/joystick_diagrams/classes/version/version.py @@ -1,7 +1,7 @@ """ Versioning for Joystick Diagrams -Author: Robert Cox +Author: https://github.com/Rexeh """ from dataclasses import dataclass import logging @@ -55,18 +55,17 @@ def fetch_local_manifest() -> str | None: def performn_version_check() -> bool: """Checks the local version against the latest release""" - # GET REMOTE JSON + remote_manifest = fetch_remote_manifest() local_manifest = fetch_local_manifest() if not remote_manifest or not local_manifest: - _LOGGER.error("Unable to perform version check") + _LOGGER.error("Unable to perform version check due to an error") return True running_version = __convert_json_to_object(local_manifest) latest_version = __convert_json_to_object(remote_manifest) - # Check Versions return compare_versions(latest_version=latest_version, running_version=running_version) diff --git a/joystick_diagrams/config.py b/joystick_diagrams/config.py index 65c181a..f5d1742 100644 --- a/joystick_diagrams/config.py +++ b/joystick_diagrams/config.py @@ -3,16 +3,8 @@ Config = ConfigParser.ConfigParser() Config.read("./config.cfg") -# Write logs -debug = Config.getboolean("Logging", "EnableLogging", fallback=1) -debugLevel = Config.getint("Logging", "LogLevel", fallback=1) +# Logging +debugLevel = Config.get("Logging", "LogLevel", fallback="INFO") # Params noBindText = Config.get("Preferences", "NoBindText", fallback="No Bind") - -# Export out SVG files - for development only (leave as = 1) -export = 1 - -## Program can automatically open in browser as it creates, specify below if you want this. Only supports Chrome right now. -openinbrowser = Config.getboolean("BROWSER", "OpenTemplatesInBrowser", fallback=0) -chrome_path = Config.get("BROWSER", "ChromePath", fallback="") diff --git a/joystick_diagrams/functions/helper.py b/joystick_diagrams/functions/helper.py index a2c93dd..f1027e8 100644 --- a/joystick_diagrams/functions/helper.py +++ b/joystick_diagrams/functions/helper.py @@ -1,6 +1,5 @@ import logging from pathlib import Path -from joystick_diagrams import version _logger = logging.getLogger(__name__) @@ -11,12 +10,3 @@ def create_directory(directory) -> None: # pylint: disable=missing-function-doc Path(directory).mkdir() except OSError as error: _logger.error(f"Failed to create directory: {directory} with {error}") - - -def get_version() -> str: - """ - Returns the current version of the application from Version File - - Returns: String - """ - return "Version: " + version.VERSION diff --git a/joystick_diagrams/logs/jv.log b/joystick_diagrams/logs/jv.log deleted file mode 100644 index e69de29..0000000