diff options
author | mahesh | 2016-04-26 14:57:18 +0530 |
---|---|---|
committer | mahesh | 2016-04-26 14:57:18 +0530 |
commit | e85df2bdab22c5ca8364683d8839148ff1f3a45d (patch) | |
tree | 5b852027c4bdcfc6c48a2a437bb272dddbe1db6f | |
parent | d1eef506331239840772cd8d5f448347fb1d4665 (diff) | |
download | Python-TBC-Interface-e85df2bdab22c5ca8364683d8839148ff1f3a45d.tar.gz Python-TBC-Interface-e85df2bdab22c5ca8364683d8839148ff1f3a45d.tar.bz2 Python-TBC-Interface-e85df2bdab22c5ca8364683d8839148ff1f3a45d.zip |
made changes to convert notebook function
-rwxr-xr-x | tbc/views.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/tbc/views.py b/tbc/views.py index f6e93ae..e866c46 100755 --- a/tbc/views.py +++ b/tbc/views.py @@ -1189,7 +1189,6 @@ def BrowseBooks(request): return render_to_response('tbc/browse-books.html', context) - def ConvertNotebook(request, notebook_path=None): """ Checks for the modified time of ipython notebooks and corresponding html page and replaces html page with new one if corresponding ipython notebook has been modified. """ @@ -1198,16 +1197,23 @@ def ConvertNotebook(request, notebook_path=None): path = os.path.join(local.path, notebook_path.strip(".ipynb")) template_html = path+".html" template_ipynb =path+".ipynb" - modified_time_for_html = os.stat(template_html).st_mtime - modified_time_for_ipynb = os.stat(template_ipynb).st_mtime + template_dir = os.path.dirname(path) + + def nbconvert(template_ipynb): + notebook_convert = "ipython nbconvert --to html {0} --FilesWriter.build_directory={1}".format(template_ipynb, template_dir) + subprocess.call (notebook_convert, shell = True) - if os.path.isfile(template_html) and modified_time_for_html > modified_time_for_ipynb: - return render_to_response(template_html, {}) - else: - notebook_convert = "ipython nbconvert --to html %s" % str(template_ipynb) - subprocess.call (notebook_convert) - return render_to_response(template_html, {}) + if os.path.isfile(template_html): + modified_time_for_html = os.stat(template_html).st_mtime + modified_time_for_ipynb = os.stat(template_ipynb).st_mtime + if not modified_time_for_html > modified_time_for_ipynb: + nbconvert(template_ipynb) + + else: + nbconvert(template_ipynb) + + return render_to_response(template_html, context) def CompletedBooks(request): |