refactor setting of local encoding; remove from top-level omniperf

wrapper and push into base class via a companion utility function

Signed-off-by: Karl W Schulz <karl.schulz@amd.com>
Este commit está contenido en:
Karl W Schulz
2024-03-08 17:20:08 -06:00
cometido por Karl W. Schulz
padre dbba0d418a
commit 27a57bdafb
Se han modificado 3 ficheros con 15 adiciones y 9 borrados
+2 -9
Ver fichero
@@ -25,23 +25,16 @@
##############################################################################el
import sys
import locale
import logging
from utils.utils import error
from omniperf_base import Omniperf
from utils.utils import console_error
def main():
try:
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
except locale.Error as e:
logging.warning("Please ensure that the 'en_US.UTF-8' locale is available on your system.")
error(f"Error setting locale: {e}")
omniperf = Omniperf()
mode = omniperf.get_mode()
# major omniperf execution modes
if mode == "profile":
omniperf.run_profiler()
+2
Ver fichero
@@ -38,6 +38,7 @@ from utils.utils import (
console_debug,
console_log,
console_error,
set_locale_encoding,
)
from utils.logger import setup_console_handler, setup_logging_priority, setup_file_handler
from argparser import omniarg_parser
@@ -57,6 +58,7 @@ SUPPORTED_ARCHS = {
class Omniperf:
def __init__(self):
set_locale_encoding()
self.__args = None
self.__profiler_mode = None
self.__analyze_mode = None
+11
Ver fichero
@@ -22,6 +22,7 @@
# SOFTWARE.
##############################################################################el
import locale
import logging
import sys
import os
@@ -593,3 +594,13 @@ def print_status(msg):
console_log(msg)
console_log("~" * (msg_length + 1))
console_log("")
def set_locale_encoding():
try:
locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
except locale.Error as error:
print("Please ensure that the 'en_US.UTF-8' locale is available on your system.")
print("")
print("ERROR: ", error)
sys.exit(1)