use NotebookManager APIs in nbconvert handler

This commit is contained in:
MinRK 2014-02-12 23:09:39 -08:00
parent cb25736a24
commit f9e8824fef

View File

@ -76,15 +76,12 @@ class NbconvertFileHandler(IPythonHandler):
exporter = get_exporter(format, config=self.config) exporter = get_exporter(format, config=self.config)
path = path.strip('/') path = path.strip('/')
os_path = self.notebook_manager.get_os_path(name, path) model = self.notebook_manager.get_notebook(name=name, path=path)
if not os.path.isfile(os_path):
raise web.HTTPError(404, u'Notebook does not exist: %s' % name)
info = os.stat(os_path) self.set_header('Last-Modified', model['last_modified'])
self.set_header('Last-Modified', tz.utcfromtimestamp(info.st_mtime))
try: try:
output, resources = exporter.from_filename(os_path) output, resources = exporter.from_notebook_node(model['content'])
except Exception as e: except Exception as e:
raise web.HTTPError(500, "nbconvert failed: %s" % e) raise web.HTTPError(500, "nbconvert failed: %s" % e)