我运行以下python代码来测试从pandoc的markdown变体生成epub/html文件的自动化程度。当我从web上运行这个程序时(即使用python和cgi),我得到一个fail和一个83的返回代码。当我从命令行运行这个程序时,它运行得非常好。它需要从网络上运行。在
我找到的唯一引用pandoc和返回代码83与pandoc citeproc有关:https://groups.google.com/forum/#!topic/pandoc-discuss/rV3eiZhwTlQ
下面的runcmd
函数在另一个程序中从web上运行,以生成pdf/LaTex而没有任何问题。在
我已经在这篇文章的末尾添加了错误输出。在
任何帮助都将不胜感激。在
#!/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)
错误输出:
在**************** 使用test1\u args运行 ****************在
命令'['/usr/bin/pandoc','--smart','--toc','--standalone','--csl=/tmp/tmp0u5dtk/acm sig-会议记录.csl','--书目=/tmp/tmp0u5dtk/biblio.围嘴','--filter=/usr/bin/pandoc citeproc','/tmp/tmp0u5dtk/G生成的PubMetadata.yaml','/tmp/tmp0u5dtk/G生成PubPreamble.md','/tmp/tmp0u5dtk/第一个_章md', '/tmp/tmp0u5dtk/另一个_章md','/tmp/tmp0u5dtk/modifiedPubAppendix.md','--输出=/tmp/tmp0u5dtk/生成doc.html“]”返回非零退出状态83
83岁
路径:['/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']
失败:/usr/bin/pandoc with('--smart','--toc','--standalone','--csl=/tmp/tmp0u5dtk/acm sig-会议记录.csl','--书目=/tmp/tmp0u5dtk/biblio.围嘴','--filter=/usr/bin/pandoc citeproc','/tmp/tmp0u5dtk/G生成的PubMetadata.yaml','/tmp/tmp0u5dtk/G生成PubPreamble.md','/tmp/tmp0u5dtk/第一个_章md', '/tmp/tmp0u5dtk/另一个_章md','/tmp/tmp0u5dtk/modifiedPubAppendix.md','--输出=/tmp/tmp0u5dtk/生成doc.html')
在**************** 使用test2_args运行 ****************在
命令'['/usr/bin/pandoc','--smart','--toc','--standalone','--csl=/tmp/tmp0u5dtk/acm sig-会议记录.csl','--书目=/tmp/tmp0u5dtk/biblio.围嘴','--filter=/usr/bin/pandoc citeproc','/tmp/tmp0u5dtk/G生成的PubMetadata.yaml','/tmp/tmp0u5dtk/G生成PubPreamble.md','/tmp/tmp0u5dtk/第一个_章md', '/tmp/tmp0u5dtk/另一个_章md','/tmp/tmp0u5dtk/modifiedPubAppendix.md','--输出=/tmp/tmp0u5dtk/生成doc.epub“]”返回非零退出状态83
83岁
路径:['/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']
失败:/usr/bin/pandoc with('--smart','--toc','--standalone','--csl=/tmp/tmp0u5dtk/acm sig-会议记录.csl','--书目=/tmp/tmp0u5dtk/biblio.围嘴','--filter=/usr/bin/pandoc citeproc','/tmp/tmp0u5dtk/G生成的PubMetadata.yaml','/tmp/tmp0u5dtk/G生成PubPreamble.md','/tmp/tmp0u5dtk/第一个_章md', '/tmp/tmp0u5dtk/另一个_章md','/tmp/tmp0u5dtk/modifiedPubAppendix.md','--输出=/tmp/tmp0u5dtk/生成doc.epub')
目前没有回答
相关问题 更多 >
编程相关推荐