--config CLI Param fix
This commit is contained in:
@@ -86,6 +86,8 @@ from eb_dashboard_utils import (
|
|||||||
clear_httpx_client,
|
clear_httpx_client,
|
||||||
get_thread_position,
|
get_thread_position,
|
||||||
get_config_path,
|
get_config_path,
|
||||||
|
set_dashboard_config_path_override,
|
||||||
|
get_dashboard_config_path,
|
||||||
thread_local_storage,
|
thread_local_storage,
|
||||||
run_with_context
|
run_with_context
|
||||||
)
|
)
|
||||||
@@ -130,7 +132,6 @@ _user_interaction_lock = threading.Lock()
|
|||||||
# Global variables (mutable, set at runtime - not constants)
|
# Global variables (mutable, set at runtime - not constants)
|
||||||
inclusions_mapping_config = []
|
inclusions_mapping_config = []
|
||||||
organizations_mapping_config = []
|
organizations_mapping_config = []
|
||||||
_dashboard_config_path_override = None # Set by --config CLI arg if provided
|
|
||||||
excel_export_config = None
|
excel_export_config = None
|
||||||
excel_export_enabled = False
|
excel_export_enabled = False
|
||||||
|
|
||||||
@@ -162,9 +163,9 @@ if "--config" in sys.argv:
|
|||||||
_raw_config_path = sys.argv[_idx + 1]
|
_raw_config_path = sys.argv[_idx + 1]
|
||||||
del sys.argv[_idx:_idx + 2]
|
del sys.argv[_idx:_idx + 2]
|
||||||
if os.path.isabs(_raw_config_path):
|
if os.path.isabs(_raw_config_path):
|
||||||
_dashboard_config_path_override = _raw_config_path
|
set_dashboard_config_path_override(_raw_config_path)
|
||||||
else:
|
else:
|
||||||
_dashboard_config_path_override = os.path.join(get_config_path(), _raw_config_path)
|
set_dashboard_config_path_override(os.path.join(get_config_path(), _raw_config_path))
|
||||||
|
|
||||||
# --- Progress Bar Configuration ---
|
# --- Progress Bar Configuration ---
|
||||||
# NOTE: BAR_N_FMT_WIDTH, BAR_TOTAL_FMT_WIDTH, BAR_TIME_WIDTH, BAR_RATE_WIDTH
|
# NOTE: BAR_N_FMT_WIDTH, BAR_TOTAL_FMT_WIDTH, BAR_TIME_WIDTH, BAR_RATE_WIDTH
|
||||||
@@ -471,7 +472,7 @@ def load_json_file(filename):
|
|||||||
def load_inclusions_mapping_config():
|
def load_inclusions_mapping_config():
|
||||||
"""Loads and validates the inclusions mapping configuration from the Excel file."""
|
"""Loads and validates the inclusions mapping configuration from the Excel file."""
|
||||||
global inclusions_mapping_config
|
global inclusions_mapping_config
|
||||||
config_path = _dashboard_config_path_override or os.path.join(get_config_path(), DASHBOARD_CONFIG_FILE_NAME)
|
config_path = get_dashboard_config_path(DASHBOARD_CONFIG_FILE_NAME)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Load with data_only=True to read calculated values instead of formulas
|
# Load with data_only=True to read calculated values instead of formulas
|
||||||
@@ -573,7 +574,7 @@ def load_inclusions_mapping_config():
|
|||||||
def load_organizations_mapping_config():
|
def load_organizations_mapping_config():
|
||||||
"""Loads and validates the organizations mapping configuration from the Excel file."""
|
"""Loads and validates the organizations mapping configuration from the Excel file."""
|
||||||
global organizations_mapping_config
|
global organizations_mapping_config
|
||||||
config_path = _dashboard_config_path_override or os.path.join(get_config_path(), DASHBOARD_CONFIG_FILE_NAME)
|
config_path = get_dashboard_config_path(DASHBOARD_CONFIG_FILE_NAME)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Load with data_only=True to read calculated values instead of formulas
|
# Load with data_only=True to read calculated values instead of formulas
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
xw = None
|
xw = None
|
||||||
|
|
||||||
from eb_dashboard_utils import get_nested_value, get_config_path
|
from eb_dashboard_utils import get_nested_value, get_config_path, get_dashboard_config_path
|
||||||
from eb_dashboard_constants import (
|
from eb_dashboard_constants import (
|
||||||
INCLUSIONS_FILE_NAME,
|
INCLUSIONS_FILE_NAME,
|
||||||
ORGANIZATIONS_FILE_NAME,
|
ORGANIZATIONS_FILE_NAME,
|
||||||
@@ -117,7 +117,7 @@ def load_excel_export_config(console_instance=None):
|
|||||||
if console_instance:
|
if console_instance:
|
||||||
console = console_instance
|
console = console_instance
|
||||||
|
|
||||||
config_path = os.path.join(get_config_path(), DASHBOARD_CONFIG_FILE_NAME)
|
config_path = get_dashboard_config_path(DASHBOARD_CONFIG_FILE_NAME)
|
||||||
error_messages = []
|
error_messages = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import shutil
|
|||||||
|
|
||||||
import openpyxl
|
import openpyxl
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from eb_dashboard_utils import get_nested_value, get_old_filename as _get_old_filename, get_config_path
|
from eb_dashboard_utils import get_nested_value, get_old_filename as _get_old_filename, get_config_path, get_dashboard_config_path
|
||||||
from eb_dashboard_constants import (
|
from eb_dashboard_constants import (
|
||||||
INCLUSIONS_FILE_NAME,
|
INCLUSIONS_FILE_NAME,
|
||||||
ORGANIZATIONS_FILE_NAME,
|
ORGANIZATIONS_FILE_NAME,
|
||||||
@@ -93,7 +93,7 @@ def load_regression_check_config(console_instance=None):
|
|||||||
if console_instance:
|
if console_instance:
|
||||||
console = console_instance
|
console = console_instance
|
||||||
|
|
||||||
config_path = os.path.join(get_config_path(), DASHBOARD_CONFIG_FILE_NAME)
|
config_path = get_dashboard_config_path(DASHBOARD_CONFIG_FILE_NAME)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
workbook = openpyxl.load_workbook(config_path)
|
workbook = openpyxl.load_workbook(config_path)
|
||||||
|
|||||||
@@ -204,6 +204,22 @@ def get_config_path():
|
|||||||
return CONFIG_FOLDER_NAME
|
return CONFIG_FOLDER_NAME
|
||||||
|
|
||||||
|
|
||||||
|
_dashboard_config_path_override = None
|
||||||
|
|
||||||
|
|
||||||
|
def set_dashboard_config_path_override(path):
|
||||||
|
"""Sets a global override for the dashboard config file path (used by --config CLI arg)."""
|
||||||
|
global _dashboard_config_path_override
|
||||||
|
_dashboard_config_path_override = path
|
||||||
|
|
||||||
|
|
||||||
|
def get_dashboard_config_path(config_file_name):
|
||||||
|
"""Returns the dashboard config file path, respecting any --config CLI override."""
|
||||||
|
if _dashboard_config_path_override:
|
||||||
|
return _dashboard_config_path_override
|
||||||
|
return os.path.join(get_config_path(), config_file_name)
|
||||||
|
|
||||||
|
|
||||||
def get_old_filename(current_filename, old_suffix="_old"):
|
def get_old_filename(current_filename, old_suffix="_old"):
|
||||||
"""Generate old backup filename from current filename.
|
"""Generate old backup filename from current filename.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user