logging improvements
This commit is contained in:
@@ -11,29 +11,30 @@ CONFIG_FILE = "version.cfg"
|
||||
|
||||
|
||||
def read_version_config():
|
||||
logger.debug(f"Start read_version_config() with config file: {CONFIG_FILE}")
|
||||
config = configparser.ConfigParser()
|
||||
logger.debug("reading config file")
|
||||
config.read(CONFIG_FILE)
|
||||
logger.debug("config file read")
|
||||
|
||||
if not os.path.exists(CONFIG_FILE):
|
||||
logger.error("Could not find path")
|
||||
return ""
|
||||
logger.error(
|
||||
f"Func: read_version_config() MSG: Could not find config file '{CONFIG_FILE}'"
|
||||
)
|
||||
return "x.x.x"
|
||||
|
||||
if "VERSION" not in config:
|
||||
logger.error("Could not find VERSION in config file")
|
||||
return ""
|
||||
logger.error(f"Could not find VERSION-variable in config file '{CONFIG_FILE}'")
|
||||
return "x.x.x"
|
||||
|
||||
try:
|
||||
v = config["VERSION"]
|
||||
major = v.get("major", "0")
|
||||
minor = v.get("minor", "0")
|
||||
patch = v.get("patch", "0")
|
||||
logger.debug(f"output: {major}.{minor}.{patch}")
|
||||
logger.debug(f"Config file read successfully. Version: {major}.{minor}.{patch}")
|
||||
return f"{major}.{minor}.{patch}"
|
||||
except Exception:
|
||||
logger.warning("Couldnt read version")
|
||||
return ""
|
||||
logger.warning("Couldn not read version from config file")
|
||||
return "x.x.x"
|
||||
|
||||
|
||||
REFIT_VERSION = f"Refit Beta {read_version_config()}"
|
||||
@@ -78,11 +79,11 @@ args = parser.parse_args()
|
||||
# Dispatcher
|
||||
# determines what code gets addressed based of the users choosen flags.
|
||||
if hasattr(args, "command_class"):
|
||||
logger.debug("In hasattr()")
|
||||
logger.debug(f"In dispatcher with args: {args}")
|
||||
Refit_Create = args.command_class
|
||||
create_command_instance = Refit_Create(args)
|
||||
create_command_instance()
|
||||
else:
|
||||
parser.print_help()
|
||||
logger.info("No input, exiting with error:1")
|
||||
logger.info("No input, exiting with exit code: 1")
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user