Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sublime
- import sublime_plugin
- import subprocess
- class CompileLatex(sublime_plugin.WindowCommand):
- def run(self):
- tex_file_path = self.window.active_view().file_name()
- if tex_file_path[-3:] != "tex":
- sublime.message_dialog("Not a .tex file")
- return
- else:
- try:
- print("building pdf")
- output_path = tex_file_path[:tex_file_path.rindex("\\")]
- subprocess.run(f'pdflatex -output-directory={output_path} -aux-directory=C:\\tmp\\ {tex_file_path}', shell=True)
- except:
- sublime.message_dialog("pdflatex failed :(")
- return
- # NOTE: Everything before this line used to work perfectly before I added what's under. Now even if I comment what's
- # under, it still won't work. Like tf??
- else:
- print("is in here")
- # pid_list = subprocess.check_output('tasklist /FI "IMAGENAME eq Acrobat.exe" /FO list', shell=True)
- # print(pid_list)
- # except subprocess.CalledProcessError:
- # print("Adobe wasn't running")
- # subprocess.Popen(f'"C:\\Program Files\\Adobe\\Acrobat DC\\Acrobat\\Acrobat.exe" {tex_file_path[:-4]}.pdf')
- # return
- # else:
- # p = pid_list.split("\x0d")[0].lstrip("PID:").lstrip()
- # print("adobe was running")
- # print(f"Killing pid: {p}")
- # subprocess.run(f"taskkill /PID {p}")
- # subprocess.Popen(f'"C:\\Program Files\\Adobe\\Acrobat DC\\Acrobat\\Acrobat.exe" {tex_file_path[:-4]}.pdf')
- return
Advertisement
Add Comment
Please, Sign In to add comment