claremacrae/markdown_to_dokuwiki.py

Improve the behaviour if pandoc isn't in the path

Closed this issue · 2 comments

This is the output, if pandoc isn't in the user's path:

'pandoc' is not recognized as an internal or external command,
operable program or batch file.
Traceback (most recent call last):
  File "markdown_to_dokuwiki.py", line 128, in <module>
    main( files )
  File "markdown_to_dokuwiki.py", line 119, in main
    convert_file( filename )
  File "markdown_to_dokuwiki.py", line 109, in convert_file
    input_file = open(tempfile, 'r' )
IOError: [Errno 2] No such file or directory: 'temp_script_output.json'

It would be better if the script recognised this, and produced a useful message, rather than carrying on and trying to read a non-existent output file.

This question provides ways to do that:

http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python

And this answer looks especially useful:

http://stackoverflow.com/a/12611523/104370

It would be good if any fix ensured that the return code from main was 1, indicating failure.

Now, if pandoc isn't in the path, the testsuite output looks like this:

'pandoc' is not recognized as an internal or external command,
operable program or batch file.
No json file created: cannot proceed
F
======================================================================
FAIL: runTest (__main__.ConversionsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "markdown_to_dokuwiki_testsuite.py", line 29, in runTest
    self.fail( "ERROR: conversion failed." )
AssertionError: ERROR: conversion failed.

----------------------------------------------------------------------
Ran 1 test in 0.092s

FAILED (failures=1)

I think this is clear enough to close the issue.