Skip to content

Commit

Permalink
ab4cfg.py: also checks for ab3cfg.sh for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
liushuyu committed Jan 9, 2024
1 parent c32ec70 commit 2afda9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion acbs/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '20240109'
__version__ = '20240109.1'
18 changes: 10 additions & 8 deletions acbs/ab4cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 2afda9d

Please sign in to comment.