Skip to content

Commit

Permalink
Fix logging levels, remove old version code
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexeh committed Nov 27, 2023
1 parent 858a898 commit 7eaa4d7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 44 deletions.
13 changes: 7 additions & 6 deletions config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
# Log level sets the amount of logs generated for Joystick Diagrams. Default is INFO.
# INFO
# WARNING
# ERROR
# CRITICAL
# DEBUG
LogLevel=INFO
23 changes: 9 additions & 14 deletions joystick_diagrams/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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__":
Expand All @@ -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)
7 changes: 3 additions & 4 deletions joystick_diagrams/classes/version/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Versioning for Joystick Diagrams
Author: Robert Cox
Author: https://github.com/Rexeh
"""
from dataclasses import dataclass
import logging
Expand Down Expand Up @@ -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)


Expand Down
12 changes: 2 additions & 10 deletions joystick_diagrams/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="")
10 changes: 0 additions & 10 deletions joystick_diagrams/functions/helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
from pathlib import Path
from joystick_diagrams import version

_logger = logging.getLogger(__name__)

Expand All @@ -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
Empty file removed joystick_diagrams/logs/jv.log
Empty file.

0 comments on commit 7eaa4d7

Please sign in to comment.