Show More
@@ -32,6 +32,7 b' from IPython.utils.importstring import import_item' | |||||
32 | from .exporters.export import export_by_name, get_export_names, ExporterNameError |
|
32 | from .exporters.export import export_by_name, get_export_names, ExporterNameError | |
33 | from IPython.nbconvert import exporters, transformers, writers |
|
33 | from IPython.nbconvert import exporters, transformers, writers | |
34 | from .utils.base import NbConvertBase |
|
34 | from .utils.base import NbConvertBase | |
|
35 | from .utils.exceptions import ConversionException | |||
35 |
|
36 | |||
36 | #----------------------------------------------------------------------------- |
|
37 | #----------------------------------------------------------------------------- | |
37 | #Classes and functions |
|
38 | #Classes and functions | |
@@ -203,12 +204,20 b' class NbConvertApp(BaseIPythonApplication):' | |||||
203 | resources=resources, |
|
204 | resources=resources, | |
204 | config=self.config) |
|
205 | config=self.config) | |
205 | except ExporterNameError as e: |
|
206 | except ExporterNameError as e: | |
206 |
print("Error: '%s' exporter not found." |
|
207 | print("Error while converting '%s': '%s' exporter not found." | |
|
208 | %(notebook_filename, self.export_format), | |||
207 | file=sys.stderr) |
|
209 | file=sys.stderr) | |
208 | print("Known exporters are:", |
|
210 | print("Known exporters are:", | |
209 | "\n\t" + "\n\t".join(get_export_names()), |
|
211 | "\n\t" + "\n\t".join(get_export_names()), | |
210 | file=sys.stderr) |
|
212 | file=sys.stderr) | |
211 | sys.exit(-1) |
|
213 | sys.exit(-1) | |
|
214 | except ConversionException as e: | |||
|
215 | print("Error while converting '%s': %s" %(notebook_filename, e), | |||
|
216 | file=sys.stderr) | |||
|
217 | sys.exit(-1) | |||
|
218 | # except Exception as e: | |||
|
219 | # print("Error: could not export '%s'" % notebook_filename, file=sys.stderr) | |||
|
220 | # print(e, file=sys.stderr) | |||
212 | else: |
|
221 | else: | |
213 | self.writer.write(output, resources, notebook_name=notebook_name) |
|
222 | self.writer.write(output, resources, notebook_name=notebook_name) | |
214 | conversion_success += 1 |
|
223 | conversion_success += 1 |
@@ -14,4 +14,4 b'' | |||||
14 | class ConversionException(Exception): |
|
14 | class ConversionException(Exception): | |
15 | """An exception raised by the conversion process.""" |
|
15 | """An exception raised by the conversion process.""" | |
16 |
|
16 | |||
17 | pass No newline at end of file |
|
17 | pass |
@@ -19,16 +19,14 b' import subprocess' | |||||
19 | # IPython imports |
|
19 | # IPython imports | |
20 | from IPython.utils.py3compat import cast_bytes |
|
20 | from IPython.utils.py3compat import cast_bytes | |
21 |
|
21 | |||
|
22 | from .exceptions import ConversionException | |||
|
23 | ||||
22 | #----------------------------------------------------------------------------- |
|
24 | #----------------------------------------------------------------------------- | |
23 | # Classes and functions |
|
25 | # Classes and functions | |
24 | #----------------------------------------------------------------------------- |
|
26 | #----------------------------------------------------------------------------- | |
25 |
|
27 | |||
26 |
class PandocMissing( |
|
28 | class PandocMissing(ConversionException): | |
27 | """Exception raised when Pandoc is missing. |
|
29 | """Exception raised when Pandoc is missing. """ | |
28 |
|
||||
29 | A subclass of SystemExit so it will cause an exit if not caught, but |
|
|||
30 | explicitly named so that it's possible to catch. |
|
|||
31 | """ |
|
|||
32 | pass |
|
30 | pass | |
33 |
|
31 | |||
34 |
|
32 | |||
@@ -61,7 +59,7 b" def pandoc(source, fmt, to, extra_args=None, encoding='utf-8'):" | |||||
61 | ) |
|
59 | ) | |
62 | except OSError as e: |
|
60 | except OSError as e: | |
63 | raise PandocMissing( |
|
61 | raise PandocMissing( | |
64 |
" |
|
62 | "The command '%s' returned an error: %s.\n" %(" ".join(command), e) + | |
65 | "Please check that pandoc is installed:\n" + |
|
63 | "Please check that pandoc is installed:\n" + | |
66 | "http://johnmacfarlane.net/pandoc/installing.html" |
|
64 | "http://johnmacfarlane.net/pandoc/installing.html" | |
67 | ) |
|
65 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now