From fbe5ee442318854498611b5642f99a146709ad3b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 5 Jan 2016 18:32:51 +0000 Subject: [PATCH] Added use of make file in export --- project/export/cli.py | 26 ++++++++++++++++++++++---- project/utils/repos.py | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/project/export/cli.py b/project/export/cli.py index 356d6b4..0a791c1 100644 --- a/project/export/cli.py +++ b/project/export/cli.py @@ -1,13 +1,16 @@ import click from project.export import exports -from project.utils import repos +from project.utils import repos, shell + + +DEFAULT = 'all' @click.command('export') -@click.argument('sections', nargs=-1) +@click.argument('sections', nargs=-1, default=DEFAULT) def cli(sections): functions = [f for k, f in exports.__dict__.items() if is_function(f)] - if sections: # If they don't want to export everything + if sections != DEFAULT: # If they don't want to export everything temp_functions = functions functions = [] for func in temp_functions: @@ -18,13 +21,28 @@ def cli(sections): try: repos.go_to_data() # Reset data directory func() + if func.__name__ in sections: + sections.remove(func) except Exception as e: errors.append(e) - + if sections: + if DEFAULT in sections: + repos.go_to_data() + out, error = shell.call("make export") + if error: + errors.append(error) + else: + for item in sections: + repos.go_to_data() + out, error = shell.call("make " + item) + if error: + errors.append(error) + break if errors: print("Errors:") for error in errors: print(error) + return 1 return 0 diff --git a/project/utils/repos.py b/project/utils/repos.py index 00c711d..b3c7069 100644 --- a/project/utils/repos.py +++ b/project/utils/repos.py @@ -58,7 +58,7 @@ def has_data(data): def go_to_data(subdir=''): - path = os.path.join(constants.PUBLIC_DATA_DIR, subdir) + path = os.path.join(constants.ALL_DATA_DIR, subdir) os.chdir(path) return path