From 2afda9dcbb9aba2d0d625f82054dfd21da22e8e1 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Tue, 9 Jan 2024 15:27:35 -0700 Subject: [PATCH] ab4cfg.py: also checks for ab3cfg.sh for compatibility --- acbs/__init__.py | 2 +- acbs/ab4cfg.py | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/acbs/__init__.py b/acbs/__init__.py index 813a433..996e640 100644 --- a/acbs/__init__.py +++ b/acbs/__init__.py @@ -1 +1 @@ -__version__ = '20240109' +__version__ = '20240109.1' diff --git a/acbs/ab4cfg.py b/acbs/ab4cfg.py index 13cd8db..a74a438 100644 --- a/acbs/ab4cfg.py +++ b/acbs/ab4cfg.py @@ -5,9 +5,9 @@ from pyparsing import ParseException # type: ignore -def is_in_stage2_file(ab4cfg_path: str) -> bool: - with open(ab4cfg_path) as f: - vars = bashvar.eval_bashvar(f.read(), filename=ab4cfg_path) +def is_in_stage2_file(abcfg_path: str) -> bool: + with open(abcfg_path) as f: + vars = bashvar.eval_bashvar(f.read(), filename=abcfg_path) stage2_val: str = vars.get('ABSTAGE2') return stage2_val == '1' return False @@ -21,12 +21,14 @@ def is_in_stage2() -> bool: """ Return whether the current environment is in a stage2 development phase. """ - ab4cfg_path: str = os.path.join(AUTOBUILD_CONF_DIR, 'ab4cfg.sh') + abcfg_path: str = os.path.join(AUTOBUILD_CONF_DIR, 'ab3cfg.sh') + if not os.path.exists(abcfg_path): + abcfg_path: str = os.path.join(AUTOBUILD_CONF_DIR, 'ab4cfg.sh') try: - return is_in_stage2_env() or is_in_stage2_file(ab4cfg_path) + return is_in_stage2_env() or is_in_stage2_file(abcfg_path) except OSError as e: - raise RuntimeError(f'Unable to read Autobuild config file {ab4cfg_path}.') from e + raise RuntimeError(f'Unable to read Autobuild config file {abcfg_path}.') from e except ParseException as e: - raise RuntimeError(f'Error occurred while parsing Autobuild config file {ab4cfg_path}.') from e + raise RuntimeError(f'Error occurred while parsing Autobuild config file {abcfg_path}.') from e except Exception as e: - raise RuntimeError(f'Error occurred while checking whether stage 2 mode is enabled.') from e + raise RuntimeError('Error occurred while checking whether stage 2 mode is enabled.') from e