From 4e454e273d6347a4c71faebb9256ce20a895e34a Mon Sep 17 00:00:00 2001 From: Martin Bless Date: Wed, 30 Aug 2017 22:16:56 +0200 Subject: [PATCH] [TASK] v1.0.0-dev Add action '-T version' --- .../run_02-Show-help-and-exit.py | 5 +- .../run_03-Run-action-and-exit.py | 57 ++++++++++--------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/10-Toolchain-actions/run_02-Show-help-and-exit.py b/10-Toolchain-actions/run_02-Show-help-and-exit.py index 87b1a7f..ed4663e 100755 --- a/10-Toolchain-actions/run_02-Show-help-and-exit.py +++ b/10-Toolchain-actions/run_02-Show-help-and-exit.py @@ -93,8 +93,9 @@ def params_get(name, default=None): Toolchain options: -T clean Let the toolchain delete prior builds, then exit. - -T help Let the toolchain show this help, then exit. - -T unlock Let the toolchain remove existing locks, then exit + -T help Show toolchain help and e exit. + -T unlock Remove possible lock and exit. + -T version Show toolchain version and exit. -c makedir PATH/TO/MAKEDIR Required! The path to the 'make' folder. -c rebuild_needed 1 Force rebuild regardless of checksum diff --git a/10-Toolchain-actions/run_03-Run-action-and-exit.py b/10-Toolchain-actions/run_03-Run-action-and-exit.py index 6888ac2..91a6882 100755 --- a/10-Toolchain-actions/run_03-Run-action-and-exit.py +++ b/10-Toolchain-actions/run_03-Run-action-and-exit.py @@ -10,6 +10,8 @@ import tct import sys +VERSION = '1.0.0-dev' + params = tct.readjson(sys.argv[1]) binabspath = sys.argv[2] facts = tct.readjson(params['factsfile']) @@ -167,37 +169,36 @@ def execute_cmdlist(cmdlist): if one is not None: exitcode_temp, cmd, out, err = execute_cmdlist(['ps', str(one)]) - if exitcode == CONTINUE: import shutil - for action in toolchain_actions: - - if action == 'help': - 'Should not occur' - - elif action == 'unlock': - for top, dirs, files in os.walk(toolchain_temp_home): - dirs[:] = [] # stop recursion - for fname in files: - if fname == lockfile_name: - lockfile = os.path.join(top, fname) - os.remove(lockfile) - lockfiles_removed.append(lockfile) - exitcode = 90 - break - - elif action == 'clean': - for top, dirs, files in os.walk(toolchain_temp_home): - dirs.sort() - for adir in dirs: - fpath = os.path.join(top, adir) - if not run_id in adir: - if os.path.isdir(fpath): - shutil.rmtree(fpath) - dirs[:] = [] # stop recursion - exitcode = 90 - break +if 'help' in toolchain_actions and exitcode == CONTINUE: + 'Should not occur' + +if 'version' in toolchain_actions and exitcode == CONTINUE: + print(VERSION) + exitcode = 90 + +if 'unlock' in toolchain_actions and exitcode == CONTINUE: + for top, dirs, files in os.walk(toolchain_temp_home): + dirs[:] = [] # stop recursion + for fname in files: + if fname == lockfile_name: + lockfile = os.path.join(top, fname) + os.remove(lockfile) + lockfiles_removed.append(lockfile) + exitcode = 90 + +if 'clean' in toolchain_actions and exitcode == CONTINUE: + for top, dirs, files in os.walk(toolchain_temp_home): + dirs.sort() + for adir in dirs: + fpath = os.path.join(top, adir) + if not run_id in adir: + if os.path.isdir(fpath): + shutil.rmtree(fpath) + dirs[:] = [] # stop recursion + exitcode = 90 # ==================================================