|
|
@ -57,7 +57,8 @@ if method == "POST":
|
|
|
|
if from_format == None:
|
|
|
|
if from_format == None:
|
|
|
|
from_format = guess_format_from_filename(f.filename)
|
|
|
|
from_format = guess_format_from_filename(f.filename)
|
|
|
|
|
|
|
|
|
|
|
|
tmp = NTF(delete=False)
|
|
|
|
# tmp = NTF(delete=False)
|
|
|
|
|
|
|
|
tmp = open('pandoc.tmp','wb')
|
|
|
|
bytes = 0
|
|
|
|
bytes = 0
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
data = f.file.read()
|
|
|
|
data = f.file.read()
|
|
|
@ -76,7 +77,10 @@ if method == "POST":
|
|
|
|
print
|
|
|
|
print
|
|
|
|
# p = subprocess.check_output('pandoc --from {0} --to {1} "{2}"'.format(ffrom, to, tmp.name), shell=True, stderr=subprocess.STDOUT)
|
|
|
|
# p = subprocess.check_output('pandoc --from {0} --to {1} "{2}"'.format(ffrom, to, tmp.name), shell=True, stderr=subprocess.STDOUT)
|
|
|
|
# print p
|
|
|
|
# print p
|
|
|
|
p = subprocess.Popen([PANDOC, '--from', from_format, '--to', to_format, tmp.name], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
if to_format is 'icml':
|
|
|
|
|
|
|
|
p = subprocess.Popen([PANDOC, '--from', 'docx', '--to', to_format,'-s', '/home/andre/public_html/oooooooooo.io/cgi-bin/pandoc.tmp'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
p = subprocess.Popen([PANDOC, '--from', 'docx', '--to', to_format, '/home/andre/public_html/oooooooooo.io/cgi-bin/pandoc.tmp', '--atx-headers'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|
|
|
|
|
|
|
|
out, err = p.communicate()
|
|
|
|
out, err = p.communicate()
|
|
|
|
print out
|
|
|
|
print out
|
|
|
@ -86,7 +90,7 @@ if method == "POST":
|
|
|
|
print
|
|
|
|
print
|
|
|
|
print u"<span style='font-family:monospace'>An error occurred, pandoc said: {0}</span>".format(e.output).format("utf-8")
|
|
|
|
print u"<span style='font-family:monospace'>An error occurred, pandoc said: {0}</span>".format(e.output).format("utf-8")
|
|
|
|
|
|
|
|
|
|
|
|
tmp.unlink(tmp.name)
|
|
|
|
# tmp.unlink(tmp.name)
|
|
|
|
|
|
|
|
|
|
|
|
###################################
|
|
|
|
###################################
|
|
|
|
# FORM/TEXT INPUT
|
|
|
|
# FORM/TEXT INPUT
|
|
|
@ -101,7 +105,11 @@ if method == "POST":
|
|
|
|
print
|
|
|
|
print
|
|
|
|
# p = subprocess.check_output('pandoc --from {0} --to {1} "{2}"'.format(ffrom, to, tmp.name), shell=True, stderr=subprocess.STDOUT)
|
|
|
|
# p = subprocess.check_output('pandoc --from {0} --to {1} "{2}"'.format(ffrom, to, tmp.name), shell=True, stderr=subprocess.STDOUT)
|
|
|
|
# print p
|
|
|
|
# print p
|
|
|
|
p = subprocess.Popen([PANDOC, '--from', from_format, '--to', to_format], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|
|
|
|
|
|
|
|
if to_format == 'icml':
|
|
|
|
|
|
|
|
p = subprocess.Popen([PANDOC, '--from', from_format, '--to', to_format , '-s'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
p = subprocess.Popen([PANDOC, '--from', from_format, '--to', to_format, '--atx-headers' ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|
|
|
|
|
|
|
|
out, err = p.communicate(text)
|
|
|
|
out, err = p.communicate(text)
|
|
|
|
print out
|
|
|
|
print out
|
|
|
|