Skip to content
Snippets Groups Projects
Commit ad5f0b23 authored by tuhe's avatar tuhe
Browse files

cmd execution

parent 1a7e5eca
Branches
No related tags found
No related merge requests found
include src/slider/DTU_Beamer_files/DTU_Beamer_files.zip
\ No newline at end of file
......@@ -10,7 +10,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
setuptools.setup(
name="beamer-slider",
version="0.1.7",
version="0.1.13",
author="Tue Herlau",
author_email="tuhe@dtu.dk",
description="Software to create inkscape overlays in Beamer",
......@@ -31,7 +31,7 @@ setuptools.setup(
python_requires=">=3.8",
install_requires=['Jinja2', 'numpy', 'chardet', 'scipy', 'seaborn', 'lxml', 'matplotlib', 'pylatexenc', 'beautifulsoup4', 'PyPDF2', 'clize'],
include_package_data=True,
package_data={'': ['DTU_Beamer_files/*.*']},
package_data={'': ['DTU_Beamer_files/DTU_Beamer_files.zip'],}, # Check Manifest.in.
entry_points={
'console_scripts': ['slider=slider.slider_cli:clize_main_entry_point'],
}
......
Metadata-Version: 2.1
Name: beamer-slider
Version: 0.1.7
Version: 0.1.13
Summary: Software to create inkscape overlays in Beamer
Home-page: https://lab.compute.dtu.dk/tuhe/slider
Author: Tue Herlau
......@@ -99,6 +99,14 @@ Thats is! And since this is an overlay, you are free to add more LaTeX to the sl
## Citing
```bibtex
@online{beamer_slider,
title={Beamer-slider (0.1.7): \texttt{pip install beamer-slider}},
url={https://lab.compute.dtu.dk/tuhe/slider},
urldate = {2021-09-08},
month={9},
publisher={Technical University of Denmark (DTU)},
author={Tue Herlau},
year={2021},
}
```
LICENSE
MANIFEST.in
README.md
pyproject.toml
setup.py
......@@ -29,3 +30,4 @@ src/slider/slide.py
src/slider/slide_fixer.py
src/slider/slider_cli.py
src/slider/slider_init.py
src/slider/DTU_Beamer_files/DTU_Beamer_files.zip
\ No newline at end of file
......@@ -8,3 +8,4 @@ matplotlib
pylatexenc
beautifulsoup4
PyPDF2
clize
File added
No preview for this file type
from jinjafy import execute_command
import os
import shutil
import subprocess
import glob
def latexmk(texfile,pdf_out=None,shell=True,cleanup=False, Linux=False):
cdir = os.getcwd()
texfile = os.path.abspath(texfile)
dname = os.path.dirname(texfile)
os.chdir(dname)
texfile = os.path.basename(texfile)
if Linux:
CMD = "latexmk -f -g -pdf -interaction=nonstopmode " + texfile
print("Running LaTeX command>> " + CMD)
s = execute_command(CMD.split(" "), shell=shell)
else:
CMD = "latexmk -f -g -pdf -shell-escape -interaction=nonstopmode " + texfile
print("Running LaTeX command>> " + CMD)
s = execute_command(CMD.split(" "),shell=shell)
s = subprocess.check_output(CMD, shell=True)
# if Linux:
# CMD = "latexmk -f -g -pdf -interaction=nonstopmode " + texfile
# print("Running LaTeX command>> " + CMD)
# s = execute_command(CMD.split(" "), shell=shell)
# else:
# CMD = "latexmk -f -g -pdf -shell-escape -interaction=nonstopmode " + texfile
# s = execute_command(CMD.split(" "),shell=shell)
#
if pdf_out:
shutil.copyfile(texfile[:-4]+".pdf", pdf_out)
else:
......@@ -24,7 +31,6 @@ def latexmk(texfile,pdf_out=None,shell=True,cleanup=False, Linux=False):
if cleanup and os.path.exists(pdf_out):
bft = ['bbl', 'blg', 'fdb_latexmk', 'fls', 'aux', 'synctex.gz', 'log']
for ex in bft:
import glob
fl = glob.glob(dname + "/*."+ex)
for f in fl:
os.remove(f)
......
......@@ -7,6 +7,8 @@ from jinjafy import jinjafy_comment
from bs4 import BeautifulSoup
import glob
from jinjafy import execute_command
import zipfile
import tempfile
CDIR = os.path.dirname(os.path.realpath(__file__))
CDIR = CDIR.replace('\\','/')
......@@ -407,6 +409,34 @@ def move_template_files(output_dir="examples/output", output_tex_file=None):
"02450_beamer_preamble.tex", # Deprecated.
'beamer_slider_preamble.tex', # The current version.
]
zipf = DTU_beamer_base + "/DTU_Beamer_files.zip"
# os.path.exists(zipf)
tmp = tempfile.mkdtemp()
# output_dir = output_dir)
# import random
# "".join( [str(random.randint(1, 10)) for _ in range(10)] )
# tmp = str(output_dir) + "/"+ "".join( [str(random.randint(1, 10)) for _ in range(10)] )
# os.mkdir(tmp)
with zipfile.ZipFile(zipf) as zip:
# for files in zip.namelist():
# data = zip.read(files, output_dir)
# myfile_path = output_dir / Path(files).name
# myfile_path.write_bytes(data)
# zip.extract(name, output_dir +"/" + os.path.basename(name))
zip.extractall(tmp)
for f in glob.glob(tmp + "/**/*.*"):
shutil.move(f, str(output_dir) + "/"+os.path.basename(f))
shutil.rmtree(tmp)
if output_tex_file != None:
assert False
return
print(f)
sd = list( zip(files_to_move, files_to_move) )
if output_tex_file:
sd.append( ("02450_lectures_base.tex", output_tex_file))
......
#!python
# The above makes the script executable.
import slider.legacy_importer
import PyPDF2
import os
from jinjafy import execute_command
# from slider import slide
from slider import legacy_importer
from slider.legacy_importer import SVG_EDIT_RELPATH, SVG_TMP_RELPATH, move_template_files, DTU_beamer_base, svg_edit_to_importable
from jinjafy.cache import cache_update_str, cache_contains_str, cache_contains_file, cache_update_file
import shutil
from slider.slide_fixer import check_svg_file_and_fix_if_broken
from slider.latexutils import latexmk
import clize
import glob
dc = "\\documentclass"
......@@ -119,7 +114,11 @@ def set_svg_background_images(lecture_tex, verbose=False,
else:
cdir = os.getcwd()
os.chdir(os.path.dirname(lecture_tex_nosvg))
execute_command(("latexmk -shell-escape -f -pdf -interaction=nonstopmode " + os.path.basename(lecture_tex_nosvg)).split(" "))
from slider import latexmk
print("Compiling latex file using latexmk...", os.path.basename(lecture_tex_nosvg))
latexmk(os.path.abspath(lecture_tex_nosvg))
# execute_command(("latexmk -shell-escape -f -pdf -interaction=nonstopmode " + os.path.basename(lecture_tex_nosvg)).split(" "))
os.chdir(cdir)
cache_update_file(MAIN_TEX_DIR, lecture_tex_nosvg)
ANY_CHANGES = True
......
......@@ -110,7 +110,7 @@ def check_svg_file_and_fix_if_broken(osvg_file, verbose=True):
s = f.read()
soup = BeautifulSoup(s, 'xml', from_encoding="UTF-8")
print("Finding all tags")
# c = 0
for j in soup.svg.find_all(recursive=False):
IL= "inkscape:label"
if IL in j.attrs and j[IL] == "bg_layer":
......
......@@ -49,7 +49,7 @@ def slider_init(latexfile=None):
if not os.path.isdir(os.path.dirname(latexfile)):
os.makedirs(os.path.dirname(latexfile))
import jinja2
# import jinja2
with open(latexfile, 'w') as f:
f.write(base_slide)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment