I'm running the following python code to test the automation of the production of epub/html files from pandoc's variant of markdown. When I run this from the web (i.e. using python and cgi), I get a fail and a return code of 83. When I run this from the command line it works perfectly. It needs to run from the web.
The only reference I've found to pandoc and return code 83 relates to pandoc-citeproc: https://groups.google.com/forum/#!topic/pandoc-discuss/rV3eiZhwTlQ
The runcmd
function below runs from the web in another program to generate pdf/LaTex without any issues.
I've added the error output to the end of this post.
Any help would be much appreciated.
#!/usr/bin/env python3
import cgi, cgitb, os, tempfile, zipfile, sys, shutil
import yaml, json, subprocess, re, datetime
# Enable module to test/debug CGI issues
cgitb.enable()
def runcmd(*args):
try:
result = subprocess.check_output(list(args), universal_newlines=True)
print("Ran command {} with {} {}".format(args[0], args[1:], result))
except subprocess.CalledProcessError as cpe:
print(str(cpe))
print(str(cpe.returncode))
print(str(cpe.output))
print("PATH: {}".format(str(sys.path)))
print("FAIL: {} with {}".format(args[0], args[1:]))
except OSError as ose:
print(str(ose))
except AttributeError as ae:
print(str(ae))
html_stuff = """Content-Type: text/html\n\n<!DOCTYPE html>\n<html lang="en">\n<head>\n<title>Generate FYP from Markdown files -- by MF</title>\n<meta charset="utf-8">\n</head>\n<body>\n<h1>Pandoc Test</h1>\n<p></p>\n<div name="messages" id="messages"></div>\n</body>\n</html>"""
print(html_stuff)
test1_args = ['/usr/bin/pandoc', '--smart', '--toc', '--standalone', '--csl=/tmp/tmp0u5dtk/acm-sig-proceedings.csl', '--bibliography=/tmp/tmp0u5dtk/biblio.bib', '--filter=/usr/bin/pandoc-citeproc', '/tmp/tmp0u5dtk/GeneratedEpubMetadata.yaml', '/tmp/tmp0u5dtk/GeneratedEpubPreamble.md', '/tmp/tmp0u5dtk/first_chapter.md', '/tmp/tmp0u5dtk/another_chapter.md', '/tmp/tmp0u5dtk/ModifiedEpubAppendix.md', '--output=/tmp/tmp0u5dtk/GeneratedDoc.html']
test2_args = ['/usr/bin/pandoc', '--smart', '--toc', '--standalone', '--csl=/tmp/tmp0u5dtk/acm-sig-proceedings.csl', '--bibliography=/tmp/tmp0u5dtk/biblio.bib', '--filter=/usr/bin/pandoc-citeproc', '/tmp/tmp0u5dtk/GeneratedEpubMetadata.yaml', '/tmp/tmp0u5dtk/GeneratedEpubPreamble.md', '/tmp/tmp0u5dtk/first_chapter.md', '/tmp/tmp0u5dtk/another_chapter.md', '/tmp/tmp0u5dtk/ModifiedEpubAppendix.md', '--output=/tmp/tmp0u5dtk/GeneratedDoc.epub']
print("<p>****************\nrunning with test1_args\n****************</p>")
runcmd(*test1_args)
print("<p>****************\nrunning with test2_args\n****************</p>")
runcmd(*test2_args)
Error output:
Pandoc Test
**************** running with test1_args ****************
Command '['/usr/bin/pandoc', '--smart', '--toc', '--standalone', '--csl=/tmp/tmp0u5dtk/acm-sig-proceedings.csl', '--bibliography=/tmp/tmp0u5dtk/biblio.bib', '--filter=/usr/bin/pandoc-citeproc', '/tmp/tmp0u5dtk/GeneratedEpubMetadata.yaml', '/tmp/tmp0u5dtk/GeneratedEpubPreamble.md', '/tmp/tmp0u5dtk/first_chapter.md', '/tmp/tmp0u5dtk/another_chapter.md', '/tmp/tmp0u5dtk/ModifiedEpubAppendix.md', '--output=/tmp/tmp0u5dtk/GeneratedDoc.html']' returned non-zero exit status 83
83
PATH: ['/var/www/cgi-bin', '/usr/lib/python3.2', '/usr/lib/python3.2/plat-linux2', '/usr/lib/python3.2/lib-dynload', '/usr/local/lib/python3.2/dist-packages', '/usr/lib/python3/dist-packages']
FAIL: /usr/bin/pandoc with ('--smart', '--toc', '--standalone', '--csl=/tmp/tmp0u5dtk/acm-sig-proceedings.csl', '--bibliography=/tmp/tmp0u5dtk/biblio.bib', '--filter=/usr/bin/pandoc-citeproc', '/tmp/tmp0u5dtk/GeneratedEpubMetadata.yaml', '/tmp/tmp0u5dtk/GeneratedEpubPreamble.md', '/tmp/tmp0u5dtk/first_chapter.md', '/tmp/tmp0u5dtk/another_chapter.md', '/tmp/tmp0u5dtk/ModifiedEpubAppendix.md', '--output=/tmp/tmp0u5dtk/GeneratedDoc.html')
**************** running with test2_args ****************
Command '['/usr/bin/pandoc', '--smart', '--toc', '--standalone', '--csl=/tmp/tmp0u5dtk/acm-sig-proceedings.csl', '--bibliography=/tmp/tmp0u5dtk/biblio.bib', '--filter=/usr/bin/pandoc-citeproc', '/tmp/tmp0u5dtk/GeneratedEpubMetadata.yaml', '/tmp/tmp0u5dtk/GeneratedEpubPreamble.md', '/tmp/tmp0u5dtk/first_chapter.md', '/tmp/tmp0u5dtk/another_chapter.md', '/tmp/tmp0u5dtk/ModifiedEpubAppendix.md', '--output=/tmp/tmp0u5dtk/GeneratedDoc.epub']' returned non-zero exit status 83
83
PATH: ['/var/www/cgi-bin', '/usr/lib/python3.2', '/usr/lib/python3.2/plat-linux2', '/usr/lib/python3.2/lib-dynload', '/usr/local/lib/python3.2/dist-packages', '/usr/lib/python3/dist-packages']
FAIL: /usr/bin/pandoc with ('--smart', '--toc', '--standalone', '--csl=/tmp/tmp0u5dtk/acm-sig-proceedings.csl', '--bibliography=/tmp/tmp0u5dtk/biblio.bib', '--filter=/usr/bin/pandoc-citeproc', '/tmp/tmp0u5dtk/GeneratedEpubMetadata.yaml', '/tmp/tmp0u5dtk/GeneratedEpubPreamble.md', '/tmp/tmp0u5dtk/first_chapter.md', '/tmp/tmp0u5dtk/another_chapter.md', '/tmp/tmp0u5dtk/ModifiedEpubAppendix.md', '--output=/tmp/tmp0u5dtk/GeneratedDoc.epub')