# you may need to import any of these;
import sublime, sublimeplugin, re, os, datetime, shutil, popen2, string, subprocess, time
# the driving code itself;
def compileLatex(latexFile):
miktexExe = miktexCommandPath("latex")
commandLine = " --interaction=nonstopmode --aux-directory c:\\temp\\ \"" + latexFile + "\""
# two compiles, to make sure contents etc are up-to-date
for i in range(2):
result = runSysCommand(miktexExe, commandLine)
if (result != 0):
return result
return 0
# call this on a command line to run it.
def runSysCommand(commandText, arguments=None):
"""executes the commands"""
print "running \"%s\" %s" % (commandText, arguments)
if arguments == None:
result = os.spawnl(os.P_WAIT, commandText)
else:
result = os.spawnl(os.P_WAIT, commandText, arguments)
if result != 0:
print "failed to execute \"%s\" %s" % (commandText, arguments)
return result
# get the program files directory
def programFiles():
prog32 = "c:\\program files"
prog64 = "c:\\program files (x86)"
if os.path.exists(prog64):
return prog64
elif os.path.exists(prog32):
return prog32
else:
raise Exception("can't find a program files")
# get the miktex command; eg miktexCommandPath("texify")
def miktexCommandPath(commandName):
return os.path.join(programFiles(), "MiKTeX 2.7\\miktex\\bin", commandName + ".exe")
Users browsing this forum: icylace and 2 guests