From f28fd2246b65efcefa2e194d21978dc22ed34c3c Mon Sep 17 00:00:00 2001 From: Taras Tsugrii Date: Tue, 3 Oct 2017 19:16:21 -0700 Subject: [PATCH] Propagate verbosity to dump script Summary: When debugging migration script it's very useful to see the debug script diagnostic as well. Test Plan: run migration script locally Reviewed By: styurin fbshipit-source-id: 4928f61 --- .../migrations/migrate_include_defs_to_load.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/migrations/migrate_include_defs_to_load.py b/scripts/migrations/migrate_include_defs_to_load.py index 850f5561559..8e8b0dbb2ec 100755 --- a/scripts/migrations/migrate_include_defs_to_load.py +++ b/scripts/migrations/migrate_include_defs_to_load.py @@ -24,18 +24,17 @@ def load_cell_roots(repo_dir: str) -> Dict[str, str]: return cell_roots -def load_export_map(repo: str, cell_roots: Dict[str, str], build_file: str): +def load_export_map(repo: str, cell_roots: Dict[str, str], build_file: str, verbose: bool = False): """Returns a dictionary with import string keys and all symbols they export as values.""" cell_root_args = [] for cell, root in cell_roots.items(): cell_root_args.extend(['--cell_root', cell + '=' + root]) - return json.loads(subprocess.check_output([ - os.path.join(MY_DIR, 'dump.py'), '--json', - '--repository', repo] + cell_root_args + [ - 'export_map', - '--use_load_function_import_string_format', - build_file - ]).decode().strip()) + dump_script = os.path.join(MY_DIR, 'dump.py') + verbosity_flags = ['-v'] if verbose else [] + export_map_flags = ['export_map', '--use_load_function_import_string_format'] + dump_command = [dump_script, '--json', '--repository', + repo] + verbosity_flags + cell_root_args + export_map_flags + [build_file] + return json.loads(subprocess.check_output(dump_command).decode().strip()) class Buildozer: @@ -104,7 +103,7 @@ def main(): buildozer = Buildozer(args.buildozer, args.repository) package_dir = os.path.dirname(args.build_file) package = str(pathlib.Path(package_dir).relative_to(args.repository)) - load_funcs = load_export_map(args.repository, cell_roots, args.build_file) + load_funcs = load_export_map(args.repository, cell_roots, args.build_file, args.verbose) logging.debug(load_funcs) add_load_funcs(buildozer, load_funcs, package) remove_include_defs(buildozer, package)