1
Fork 0

Added use of make file in export

This commit is contained in:
Jake Howard 2016-01-05 18:32:51 +00:00
parent 19f8115c4a
commit fbe5ee4423
2 changed files with 23 additions and 5 deletions

View file

@ -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

View file

@ -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