diff --git a/tests/info.yml b/tests/info.yml new file mode 100644 index 0000000..4ab1e57 --- /dev/null +++ b/tests/info.yml @@ -0,0 +1 @@ +info: \ No newline at end of file diff --git a/tw_pywrap/cli.py b/tw_pywrap/cli.py index ec26ac1..0a25d3e 100644 --- a/tw_pywrap/cli.py +++ b/tw_pywrap/cli.py @@ -55,6 +55,7 @@ def __init__(self, tw, list_for_add_method): def handle_block(self, block, args): # Handles a block of commands by calling the appropriate function. block_handler_map = { + "info": lambda tw, args: helper.handle_generic_block(tw, "info", args, method_name=None), "teams": (helper.handle_teams), "participants": (helper.handle_participants), "compute-envs": lambda tw, args: helper.handle_generic_block( diff --git a/tw_pywrap/helper.py b/tw_pywrap/helper.py index 1977f49..8e03674 100644 --- a/tw_pywrap/helper.py +++ b/tw_pywrap/helper.py @@ -3,9 +3,10 @@ Including handling methods for each block in the YAML file, and parsing methods for each block in the YAML file. """ + import yaml from tw_pywrap import utils - +import logging def parse_yaml_block(file_path, block_name): # Load the YAML file. @@ -22,6 +23,11 @@ def parse_yaml_block(file_path, block_name): name_values = set() # Iterate over each item in the block. + # If no commands supplied just run `tw ` + if block is None: + logging.warn(f"No arguments applied to {block_name}") + block = [{}] # List of empty dict + for item in block: cmd_args = parse_block(block_name, item) name = find_name(cmd_args) @@ -213,7 +219,6 @@ def handle_generic_block(tw, block, args, method_name="add"): else: method(method_name, *args) - def handle_teams(tw, args): cmd_args, members_cmd_args = args tw.teams("add", *cmd_args) diff --git a/tw_pywrap/tower.py b/tw_pywrap/tower.py index 58f5385..c347983 100644 --- a/tw_pywrap/tower.py +++ b/tw_pywrap/tower.py @@ -65,7 +65,6 @@ def _tw_run(self, cmd, *args, **kwargs): ) stdout, _ = process.communicate() stdout = stdout.decode("utf-8").strip() - # Error handling for stdout if stdout: if re.search(r"ERROR: (?!A pipeline).* already exists", stdout): @@ -81,8 +80,9 @@ def _tw_run(self, cmd, *args, **kwargs): elif to_json is True: return json.loads(stdout) else: + logging.info(stdout) return stdout - + # Allow any 'tw' subcommand to be called as a method. def __getattr__(self, cmd): """