Skip to content

Commit

Permalink
fix unhandled error when output dir is not specified during collect
Browse files Browse the repository at this point in the history
Pegleg is tossing an error that's difficult to decipher when an output
directory is not specified during "collect". Currently "save-location"
param is optional and can be missed during command execution. This PS
handles missing or invalid output directory exception.

Change-Id: I6f41e4951be29d8ecdce73f6090f0bcc9e7ee2d9
  • Loading branch information
pallavgupta committed Jun 7, 2018
1 parent 97ef079 commit d969212
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/bin/pegleg/pegleg/cli.py
Expand Up @@ -69,7 +69,6 @@ def site(primary_repo, aux_repo):
'save_location',
type=click.Path(
file_okay=False, dir_okay=True, writable=True, resolve_path=True),
default=sys.stdout,
help='Where to output')
@click.argument('site_name')
def collect(*, save_location, site_name):
Expand Down
4 changes: 4 additions & 0 deletions src/bin/pegleg/pegleg/engine/site.py
Expand Up @@ -29,6 +29,10 @@
def collect(site_name, save_location):
try:
save_files = dict()
if save_location is None:
raise ValueError('Missing param: save-location')
elif not os.path.exists(save_location):
raise FileNotFoundError('Invalid save-location path')
for (repo_base,
filename) in util.definition.site_files_by_repo(site_name):
repo_name = os.path.normpath(repo_base).split(os.sep)[-1]
Expand Down

0 comments on commit d969212

Please sign in to comment.