diff --git a/cm-cli.py b/cm-cli.py index eb17f9a..908c793 100644 --- a/cm-cli.py +++ b/cm-cli.py @@ -27,7 +27,7 @@ if not (len(sys.argv) == 2 and sys.argv[1] in ['save-snapshot', 'restore-depende f" restore-snapshot \n" f" cli-only-mode [enable|disable]\n" f" restore-dependencies\n" - f" node-in-workflow \n" + f" deps-in-workflow --workflow --output \n" f" clear\n") exit(-1) @@ -499,11 +499,39 @@ def save_snapshot(): return core.save_snapshot_with_postfix('snapshot', output_path) -def node_in_workflow(input_path, output_path): +def deps_in_workflow(): + input_path = None + output_path = None + + for i in range(len(sys.argv)): + if sys.argv[i] == '--workflow' and len(sys.argv) > i and not sys.argv[i+1].startswith('-'): + input_path = sys.argv[i+1] + + elif sys.argv[i] == '--output' and len(sys.argv) > i and not sys.argv[i+1].startswith('-'): + output_path = sys.argv[i+1] + + if input_path is None: + print(f"missing arguments: --workflow ") + exit(-1) + elif not os.path.exists(input_path): + print(f"File not founed: {input_path}") + exit(-1) + + + if output_path is None: + print(f"missing arguments: --output ") + exit(-1) + + print(f"{input_path}, {output_path}") + used_exts, unknown_nodes = asyncio.run(core.extract_nodes_from_workflow(input_path)) + custom_nodes = {} + for x in used_exts: + custom_nodes[x] = core.simple_check_custom_node(x) + res = { - 'custom_nodes': list(used_exts), + 'custom_nodes': custom_nodes, 'unknown_nodes': list(unknown_nodes) } @@ -592,12 +620,12 @@ elif op == 'cli-only-mode': else: print(f"\ninvalid value for cli-only-mode: {sys.argv[2]}\n") -elif op == "nodes-in-workflow": +elif op == "deps-in-workflow": if len(sys.argv) < 4: - print(f"missing arguments: python cm-cli.py ") + print(f"missing arguments: python cm-cli.py --workflow --output ") exit(-1) - node_in_workflow(sys.argv[2], sys.argv[3]) + deps_in_workflow() elif op == 'save-snapshot': path = save_snapshot() diff --git a/glob/manager_core.py b/glob/manager_core.py index 8a1a364..de54323 100644 --- a/glob/manager_core.py +++ b/glob/manager_core.py @@ -854,6 +854,7 @@ def update_path(repo_path, instant_execution=False): else: return "skipped" + def lookup_customnode_by_url(data, target): for x in data['custom_nodes']: if target in x['files']: @@ -868,6 +869,17 @@ def lookup_customnode_by_url(data, target): return None +def simple_check_custom_node(url): + dir_name = os.path.splitext(os.path.basename(url))[0].replace(".git", "") + dir_path = os.path.join(custom_nodes_path, dir_name) + if os.path.exists(dir_path): + return 'installed' + elif os.path.exists(dir_path+'.disabled'): + return 'disabled' + + return 'not-installed' + + def check_a_custom_node_installed(item, do_fetch=False, do_update_check=True, do_update=False): item['installed'] = 'None' @@ -1009,7 +1021,7 @@ def save_snapshot_with_postfix(postfix, path=None): return path -async def extract_nodes_from_workflow(filepath): +async def extract_nodes_from_workflow(filepath, mode='local', channel_url='default'): # prepare json data workflow = None if filepath.endswith('.json'): @@ -1060,7 +1072,7 @@ async def extract_nodes_from_workflow(filepath): extract_nodes(x) # lookup dependent custom nodes - ext_map = await get_data_by_mode('local', 'extension-node-map.json') + ext_map = await get_data_by_mode(mode, 'extension-node-map.json', channel_url) rext_map = {} preemption_map = {}