Skip to content

Commit

Permalink
Merge pull request #37 from QuantEcon/add-view-dircheck
Browse files Browse the repository at this point in the history
FEAT: Add view directory check
  • Loading branch information
mmcky committed Aug 2, 2019
2 parents 51a65ac + 51847ab commit eb7513b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions jupinx/cmd/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ def check_directory_makefile(arg_dict):
logging.error("Makefile not found in the directory")
return False

def check_view_result_directory(target, arg_dict):
if target == "notebooks":
dir = arg_dict['directory'] + "_build/jupyter/"
elif target == "website":
dir = arg_dict['directory'] + "_build/website/jupyter_html/"
else:
logging.error("target must be directory or website for the -v, --view option")
if os.path.exists(dir) is False:
if target == "notebooks":
logging.error("Results directory: {} does not exist!\nPlease run jupinx -n to build notebooks".format(dir))
elif target == "website":
logging.error("Results directory: {} does not exist.\n Please run jupinx -w to build website".format(dir))
return False

def handle_make_parallel(cmd, arg_dict):
if check_directory_makefile(arg_dict) is False:
exit()
Expand Down Expand Up @@ -145,6 +159,8 @@ def handle_make_preview(arg_dict):
if check_directory_makefile(arg_dict) is False:
exit()
target = str(arg_dict['view']).lower()
if check_view_result_directory(target, arg_dict) is False:
exit()
if target == "website":
cmd = ['make', 'preview', 'target=website', 'PORT=8900']
print("Running: " + " ".join(cmd))
Expand Down

0 comments on commit eb7513b

Please sign in to comment.