Guest User

Untitled

a guest
Jul 15th, 2023
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. import sublime
  2. import sublime_plugin
  3. import subprocess
  4.  
  5. class CompileLatex(sublime_plugin.WindowCommand):
  6. def run(self):
  7. tex_file_path = self.window.active_view().file_name()
  8.  
  9. if tex_file_path[-3:] != "tex":
  10. sublime.message_dialog("Not a .tex file")
  11. return
  12. else:
  13. try:
  14. print("building pdf")
  15. output_path = tex_file_path[:tex_file_path.rindex("\\")]
  16. subprocess.run(f'pdflatex -output-directory={output_path} -aux-directory=C:\\tmp\\ {tex_file_path}', shell=True)
  17. except:
  18. sublime.message_dialog("pdflatex failed :(")
  19. return
  20. # NOTE: Everything before this line used to work perfectly before I added what's under. Now even if I comment what's
  21. # under, it still won't work. Like tf??
  22. else:
  23. print("is in here")
  24. # pid_list = subprocess.check_output('tasklist /FI "IMAGENAME eq Acrobat.exe" /FO list', shell=True)
  25. # print(pid_list)
  26. # except subprocess.CalledProcessError:
  27. # print("Adobe wasn't running")
  28. # subprocess.Popen(f'"C:\\Program Files\\Adobe\\Acrobat DC\\Acrobat\\Acrobat.exe" {tex_file_path[:-4]}.pdf')
  29. # return
  30. # else:
  31.  
  32. # p = pid_list.split("\x0d")[0].lstrip("PID:").lstrip()
  33. # print("adobe was running")
  34. # print(f"Killing pid: {p}")
  35. # subprocess.run(f"taskkill /PID {p}")
  36.  
  37. # subprocess.Popen(f'"C:\\Program Files\\Adobe\\Acrobat DC\\Acrobat\\Acrobat.exe" {tex_file_path[:-4]}.pdf')
  38. return
Advertisement
Add Comment
Please, Sign In to add comment