Skip to content

Commit

Permalink
Merge 3aea868 into 74ef2a4
Browse files Browse the repository at this point in the history
  • Loading branch information
czue committed May 25, 2020
2 parents 74ef2a4 + 3aea868 commit 54bb7ca
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions commcare_export/cli.py
Expand Up @@ -250,15 +250,16 @@ def evaluate_query(env, query):
try:
lazy_result = query.eval(env)
force_lazy_result(lazy_result)
return 0
except requests.exceptions.RequestException as e:
if e.response.status_code == 401:
print("\nAuthentication failed. Please check your credentials.", file=sys.stderr)
return None
return EXIT_STATUS_ERROR
else:
raise
except KeyboardInterrupt:
print('\nExport aborted')
return None
print('\nExport aborted', file=sys.stderr)
return EXIT_STATUS_ERROR


def main_with_args(args):
Expand Down Expand Up @@ -315,11 +316,13 @@ def main_with_args(args):
| EmitterEnv(writer)
)

evaluate_query(env, query)
exit_status = evaluate_query(env, query)

if args.output_format == 'json':
print(json.dumps(list(writer.tables.values()), indent=4, default=RepeatableIterator.to_jvalue))

return exit_status


def entry_point():
main(sys.argv[1:])
Expand Down

0 comments on commit 54bb7ca

Please sign in to comment.