mirror of
https://github.com/moparisthebest/xeps
synced 2025-01-31 07:20:09 -05:00
Making the verbose mode work.
git-svn-id: file:///home/ksmith/gitmigration/svn/xmpp/trunk@3507 4b5297f7-1745-476d-ba37-a9c6900126ab
This commit is contained in:
parent
214c4266c6
commit
149aa9f2f4
51
gen.py
51
gen.py
@ -42,13 +42,22 @@ import getopt
|
|||||||
XEPPATH = "/var/www/vhosts/xmpp.org/extensions"
|
XEPPATH = "/var/www/vhosts/xmpp.org/extensions"
|
||||||
BUILDDICT = "/var/xsf/xepbuild.dict"
|
BUILDDICT = "/var/xsf/xepbuild.dict"
|
||||||
|
|
||||||
verbose = 0
|
VERBOSE = False
|
||||||
last_build = {}
|
last_build = {}
|
||||||
|
|
||||||
def filebase( filename ):
|
def filebase( filename ):
|
||||||
return os.path.splitext(os.path.basename(filename))[0]
|
return os.path.splitext(os.path.basename(filename))[0]
|
||||||
|
|
||||||
|
|
||||||
|
def checkError( error, desc):
|
||||||
|
global verbose
|
||||||
|
|
||||||
|
if error != 0:
|
||||||
|
if verbose:
|
||||||
|
print "Error: ", desc
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def fileHash( filename ):
|
def fileHash( filename ):
|
||||||
f = open(filename, "rb")
|
f = open(filename, "rb")
|
||||||
import hashlib
|
import hashlib
|
||||||
@ -76,19 +85,19 @@ def saveDict( filename, di ):
|
|||||||
def buildXHTML( file ):
|
def buildXHTML( file ):
|
||||||
nr = re.match("xep-(\d\d\d\d).xml", file).group(1)
|
nr = re.match("xep-(\d\d\d\d).xml", file).group(1)
|
||||||
error, desc = commands.getstatusoutput("xsltproc xep.xsl xep-" + nr + ".xml > " + XEPPATH + "/xep-" + nr + ".html")
|
error, desc = commands.getstatusoutput("xsltproc xep.xsl xep-" + nr + ".xml > " + XEPPATH + "/xep-" + nr + ".html")
|
||||||
if error != 0:
|
if not checkError(error, desc):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
error, desc = commands.getstatusoutput("xsltproc ref.xsl xep-" + nr + ".xml > " + XEPPATH + "/refs/reference.XSF.XEP-" + nr + ".xml")
|
error, desc = commands.getstatusoutput("xsltproc ref.xsl xep-" + nr + ".xml > " + XEPPATH + "/refs/reference.XSF.XEP-" + nr + ".xml")
|
||||||
if error != 0:
|
if not checkError(error, desc):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
error, desc = commands.getstatusoutput("xsltproc examples.xsl xep-" + nr + ".xml > " + XEPPATH + "/examples/" + nr + ".xml")
|
error, desc = commands.getstatusoutput("xsltproc examples.xsl xep-" + nr + ".xml > " + XEPPATH + "/examples/" + nr + ".xml")
|
||||||
if error != 0:
|
if not checkError(error, desc):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
error, desc = commands.getstatusoutput(" cp xep-" + nr + ".xml " + XEPPATH + "/")
|
error, desc = commands.getstatusoutput(" cp xep-" + nr + ".xml " + XEPPATH + "/")
|
||||||
if error != 0:
|
if not checkError(error, desc):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -96,22 +105,16 @@ def buildPDF( file ):
|
|||||||
nr = re.match("xep-(\d\d\d\d).xml", file).group(1)
|
nr = re.match("xep-(\d\d\d\d).xml", file).group(1)
|
||||||
|
|
||||||
error, desc = commands.getstatusoutput("xsltproc -o /tmp/xepbuilder/xep-" + nr + ".tex.xml xep2texml.xsl xep-" + nr + ".xml")
|
error, desc = commands.getstatusoutput("xsltproc -o /tmp/xepbuilder/xep-" + nr + ".tex.xml xep2texml.xsl xep-" + nr + ".xml")
|
||||||
if error != 0:
|
if not checkError(error, desc):
|
||||||
if verbose == 1:
|
|
||||||
print "Error: ", desc
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
error, desc = commands.getstatusoutput("texml -e utf8 /tmp/xepbuilder/xep-" + nr + ".tex.xml /tmp/xepbuilder/xep-" + nr + ".tex")
|
error, desc = commands.getstatusoutput("texml -e utf8 /tmp/xepbuilder/xep-" + nr + ".tex.xml /tmp/xepbuilder/xep-" + nr + ".tex")
|
||||||
if error != 0:
|
if not checkError(error, desc):
|
||||||
if verbose == 1:
|
|
||||||
print "Error: ", desc
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#detect http urls and escape them to make them breakable
|
#detect http urls and escape them to make them breakable
|
||||||
error, desc = commands.getstatusoutput('''sed -i 's|\([\s"]\)\(http://[^ "]*\)|\1\\path{\2}|g' /tmp/xepbuilder/xep-''' + nr + ".tex")
|
error, desc = commands.getstatusoutput('''sed -i 's|\([\s"]\)\(http://[^ "]*\)|\1\\path{\2}|g' /tmp/xepbuilder/xep-''' + nr + ".tex")
|
||||||
if error != 0:
|
if not checkError(error, desc):
|
||||||
if verbose == 1:
|
|
||||||
print "Error: ", desc
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#adjust references
|
#adjust references
|
||||||
@ -122,34 +125,26 @@ def buildPDF( file ):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
error, desc = commands.getstatusoutput('''sed -i 's|\\pageref{#\([^}]*\)}|\\pageref{\1}|g' /tmp/xepbuilder/xep-''' + nr + ".tex")
|
error, desc = commands.getstatusoutput('''sed -i 's|\\pageref{#\([^}]*\)}|\\pageref{\1}|g' /tmp/xepbuilder/xep-''' + nr + ".tex")
|
||||||
if error != 0:
|
if not checkError(error, desc):
|
||||||
if verbose == 1:
|
|
||||||
print "Error: ", desc
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
olddir = os.getcwd()
|
olddir = os.getcwd()
|
||||||
os.chdir("/tmp/xepbuilder")
|
os.chdir("/tmp/xepbuilder")
|
||||||
|
|
||||||
error, desc = commands.getstatusoutput("xelatex -interaction=batchmode xep-" + nr + ".tex")
|
error, desc = commands.getstatusoutput("xelatex -interaction=batchmode xep-" + nr + ".tex")
|
||||||
if error != 0:
|
if not checkError(error, desc):
|
||||||
if verbose == 1:
|
|
||||||
print "Error: ", desc
|
|
||||||
os.chdir(olddir)
|
os.chdir(olddir)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
error, desc = commands.getstatusoutput("xelatex -interaction=batchmode xep-" + nr + ".tex")
|
error, desc = commands.getstatusoutput("xelatex -interaction=batchmode xep-" + nr + ".tex")
|
||||||
if error != 0:
|
if not checkError(error, desc):
|
||||||
if verbose == 1:
|
|
||||||
print "Error: ", desc
|
|
||||||
os.chdir(olddir)
|
os.chdir(olddir)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
os.chdir(olddir)
|
os.chdir(olddir)
|
||||||
|
|
||||||
error, desc = commands.getstatusoutput("cp /tmp/xepbuilder/xep-" + nr + ".pdf " + XEPPATH + "/")
|
error, desc = commands.getstatusoutput("cp /tmp/xepbuilder/xep-" + nr + ".pdf " + XEPPATH + "/")
|
||||||
if error != 0:
|
if not checkError(error, desc):
|
||||||
if verbose == 1:
|
|
||||||
print "Error: ", desc
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -176,6 +171,8 @@ def usage():
|
|||||||
print "-v Enable verbose output for debugging."
|
print "-v Enable verbose output for debugging."
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
global verbose
|
||||||
|
|
||||||
try:
|
try:
|
||||||
options, remainder = getopt.gnu_getopt(argv, "v")
|
options, remainder = getopt.gnu_getopt(argv, "v")
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
@ -184,7 +181,7 @@ def main(argv):
|
|||||||
|
|
||||||
for opt, arg in options:
|
for opt, arg in options:
|
||||||
if opt in ('-v'):
|
if opt in ('-v'):
|
||||||
verbose = 1
|
verbose = True
|
||||||
|
|
||||||
xep = remainder[0]
|
xep = remainder[0]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user