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

updates

parent 57cf8d45
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,8 @@ pexpect ...@@ -8,7 +8,8 @@ pexpect
matplotlib matplotlib
numpy numpy
pycode_similar pycode_similar
# jinjafy
beamer-slider beamer-slider
tinydb tinydb
python-gitlab python-gitlab
sphinx>=6.0.0
docutils>=0.20.0
\ No newline at end of file
...@@ -13,7 +13,7 @@ with open("README.md", "r", encoding="utf-8") as fh: ...@@ -13,7 +13,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
setuptools.setup( setuptools.setup(
name="coursebox", name="coursebox",
version="0.1.19.11", version="0.1.20.1",
author="Tue Herlau", author="Tue Herlau",
author_email="tuhe@dtu.dk", author_email="tuhe@dtu.dk",
description="A course management system currently used at DTU", description="A course management system currently used at DTU",
......
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: coursebox Name: coursebox
Version: 0.1.19.11 Version: 0.1.20.1
Summary: A course management system currently used at DTU Summary: A course management system currently used at DTU
Home-page: https://lab.compute.dtu.dk/tuhe/coursebox Home-page: https://lab.compute.dtu.dk/tuhe/coursebox
Author: Tue Herlau Author: Tue Herlau
......
...@@ -192,7 +192,7 @@ def lectures(info, pensum=None): ...@@ -192,7 +192,7 @@ def lectures(info, pensum=None):
else: else:
d = d + timedelta(days=dd[i-0] if i > 1 else 0) d = d + timedelta(days=(dd+[0 for _ in range(10)])[i] if i > 1 else 0)
d = d.replace(hour=ice['hour'][i-1], minute=ice['minute'][i-1]) d = d.replace(hour=ice['hour'][i-1], minute=ice['minute'][i-1])
...@@ -203,7 +203,12 @@ def lectures(info, pensum=None): ...@@ -203,7 +203,12 @@ def lectures(info, pensum=None):
linfo['reading_long'] = ir.replace("C", "Chapter ") if ir else "" linfo['reading_long'] = ir.replace("C", "Chapter ") if ir else ""
hwp = linfo['homework_problems'] hwp = linfo['homework_problems']
# if str(hwp).strip().endswith(","):
# hwp = hwp[:-1]
linfo['homework_problems_long'] = str(hwp) if isinstance(hwp, int) else (hwp.replace("P", "Problem ") if hwp else "") linfo['homework_problems_long'] = str(hwp) if isinstance(hwp, int) else (hwp.replace("P", "Problem ") if hwp else "")
if linfo["learning_objectives"]: if linfo["learning_objectives"]:
linfo["learning_objectives"] = [s.strip() for s in linfo["learning_objectives"].split("\n")] linfo["learning_objectives"] = [s.strip() for s in linfo["learning_objectives"].split("\n")]
linfo['reading_rst'] = bib2rst(linfo['reading']) linfo['reading_rst'] = bib2rst(linfo['reading'])
...@@ -379,6 +384,7 @@ def class_information(verbose=False, ...@@ -379,6 +384,7 @@ def class_information(verbose=False,
d['CE2'] = gi.get("days", 5) == 2 if continuing_education_mode else False d['CE2'] = gi.get("days", 5) == 2 if continuing_education_mode else False
d['CE5'] = gi.get("days", 5) == 5 if continuing_education_mode else False d['CE5'] = gi.get("days", 5) == 5 if continuing_education_mode else False
d['CE'] = True if continuing_education_mode else False
d['freeze_report_evaluation'] = d['freeze_report_evaluation'] == 'True' d['freeze_report_evaluation'] = d['freeze_report_evaluation'] == 'True'
d['freeze_grades'] = d['freeze_grades'] == 'True' d['freeze_grades'] = d['freeze_grades'] == 'True'
......
...@@ -54,8 +54,13 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop ...@@ -54,8 +54,13 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop
# from cp_box.material.student_files import setup_student_files # from cp_box.material.student_files import setup_student_files
# from coursebox.material.homepage_lectures_exercises import set # from coursebox.material.homepage_lectures_exercises import set
from coursebox.student_files.student_files import setup_student_files from coursebox.student_files.student_files import setup_student_files
from coursebox.core.info import class_information
from coursebox.core import info_paths
info = class_information()
BOOK_PDF_NAME = os.path.basename(info.get('lecture_notes_tex', paths['course_number'] + "_Notes.pdf"))[:-4] + ".pdf"
if os.path.isfile(d_ := f"{paths['book']}/{paths['course_number']}_Notes.pdf"): if os.path.isfile(d_ := f"{paths['book']}/{BOOK_PDF_NAME}"):
book_frontpage_png = paths['shared']+"/figures/book.png" book_frontpage_png = paths['shared']+"/figures/book.png"
slide_to_image(d_, book_frontpage_png, page_to_take=1) slide_to_image(d_, book_frontpage_png, page_to_take=1)
image = PIL.Image.open(book_frontpage_png) image = PIL.Image.open(book_frontpage_png)
...@@ -67,10 +72,7 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop ...@@ -67,10 +72,7 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop
""" Return extra information required for building the documentation. """ Return extra information required for building the documentation.
""" """
# from coursebox.core.info_paths import get_paths # from coursebox.core.info_paths import get_paths
from coursebox.core.info import class_information
from coursebox.core import info_paths
# paths = get_paths()
info = class_information()
# {{ (date1|to_datetime - date2|to_datetime).days < lecture['show_slides_after'] }} # {{ (date1|to_datetime - date2|to_datetime).days < lecture['show_slides_after'] }}
# (info['lectures'][2]['date'].now() - info['lectures'][2]['date']).days < lecture['show_slides_after'] }} # (info['lectures'][2]['date'].now() - info['lectures'][2]['date']).days < lecture['show_slides_after'] }}
source = _get_source(paths) source = _get_source(paths)
...@@ -144,7 +146,7 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop ...@@ -144,7 +146,7 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop
shutil.copy(g, dst) shutil.copy(g, dst)
pdfs.append(dst) pdfs.append(dst)
for g in [paths['pdf_out'] + "/" + paths['course_number'] + "_Notes.pdf"]: for g in [paths['pdf_out'] + "/" + BOOK_PDF_NAME]:
dst = paths['02450public'] + "/src/docs/assets/" + os.path.basename(g) dst = paths['02450public'] + "/src/docs/assets/" + os.path.basename(g)
shutil.copy(g, dst) shutil.copy(g, dst)
pdfs.append(dst) pdfs.append(dst)
...@@ -218,10 +220,8 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop ...@@ -218,10 +220,8 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop
# subprocess.run(cmd, shell=True) # subprocess.run(cmd, shell=True)
# subprocess.run('cd "C:/Users/tuhe/Documents/02002students_complete/docs" && set PYTHONPATH="C:/Users/tuhe/Documents/02002students_complete" && sphinx-build -b html source "../../02002public/public" -a ', shell=True) # subprocess.run('cd "C:/Users/tuhe/Documents/02002students_complete/docs" && set PYTHONPATH="C:/Users/tuhe/Documents/02002students_complete" && sphinx-build -b html source "../../02002public/public" -a ', shell=True)
problems = [] problems = []
if os.name == "nt": if os.name == "nt":
# do win specific stuff here. # do win specific stuff here.
# >> > result = subprocess.run(['ls', '-l'], stdout=subprocess.PIPE) # >> > result = subprocess.run(['ls', '-l'], stdout=subprocess.PIPE)
# >> > result.stdout # >> > result.stdout
...@@ -235,19 +235,15 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop ...@@ -235,19 +235,15 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop
"""r """r
cd /home/tuhe/Documents/02465students_complete/ && sphinx-build -b html docs/source ./public cd /home/tuhe/Documents/02465students_complete/ && sphinx-build -b html docs/source ./public
cd "/home/tuhe/Documents/02465students_complete/docs" && sphinx-build -b html source "../../02465public/public" -a cd "/home/tuhe/Documents/02465students_complete/docs" && sphinx-build -b html source "../../02465public/public" -a
""" """
if os.name == 'nt': if os.name == 'nt':
# time.sleep(10)
process = run(cmd, print_output=True, log_output=True, check=False, env=my_env) process = run(cmd, print_output=True, log_output=True, check=False, env=my_env)
print("TH 2023 Juli: Running sphinx compilation job twice bc of path error on windows. This should be easy to fix but I don't know enough about windows to do so.") print("TH 2023 Juli: Running sphinx compilation job twice bc of path error on windows. This should be easy to fix but I don't know enough about windows to do so.")
print(process.stderr.getvalue()) print(process.stderr.getvalue())
errors = process.stderr.getvalue() errors = process.stderr.getvalue()
file = f"{os.path.normpath(PUBLIC_BUILD_DEST)}/log_{l}.txt" file = f"{os.path.normpath(PUBLIC_BUILD_DEST)}/log_{l}.txt"
fns.append(file) fns.append(file)
if not os.path.isdir(d_ := os.path.dirname(file)): if not os.path.isdir(d_ := os.path.dirname(file)):
os.makedirs(d_) os.makedirs(d_)
with open(file,'w') as f: with open(file,'w') as f:
......
...@@ -528,15 +528,12 @@ def make_exercises_projects_tutors(week=None, only_exercises=False, make_exercis ...@@ -528,15 +528,12 @@ def make_exercises_projects_tutors(week=None, only_exercises=False, make_exercis
"R": lang == "R", "R": lang == "R",
'HOMEWORK_PROBLEMS': HOMEWORK_PROBLEMS, 'HOMEWORK_PROBLEMS': HOMEWORK_PROBLEMS,
} }
# get lang dir # get lang dir
if not os.path.exists("%s/Exercises%s"%(paths['exercises'], lang)): if not os.path.exists("%s/Exercises%s"%(paths['exercises'], lang)):
continue continue
info.update(tv) info.update(tv)
ex_base = "%s/ExercisesShared/%sex%i_Base.tex"%(paths['exercises'], course_number, w) ex_base = "%s/ExercisesShared/%sex%i_Base.tex"%(paths['exercises'], course_number, w)
ex_tex_out = "%s/Exercises%s/Exercise%i/latex/%sex%i_%s.tex" % ( paths['exercises'], lang, w, course_number, w, lang) ex_tex_out = "%s/Exercises%s/Exercise%i/latex/%sex%i_%s.tex" % ( paths['exercises'], lang, w, course_number, w, lang)
# fbody = os.path.dirname(ex_tex_out) +f"/ex{w}_body.tex"
if os.path.exists(ex_base): if os.path.exists(ex_base):
jinjafy_template(info, ex_base, file_out=ex_tex_out, filters=filters, template_searchpath=paths['exercises']) jinjafy_template(info, ex_base, file_out=ex_tex_out, filters=filters, template_searchpath=paths['exercises'])
......
...@@ -67,8 +67,13 @@ def lecture_question_compiler(paths, info, lecture_texfile): ...@@ -67,8 +67,13 @@ def lecture_question_compiler(paths, info, lecture_texfile):
print("png_out", png_out) print("png_out", png_out)
slide_to_image(lecture_pdffile, png_out, page_to_take=n) slide_to_image(lecture_pdffile, png_out, page_to_take=n)
if dex < 0: if dex < 0:
execute_command(["pdftocairo", fout_q_pdf, fout_q_pdf[:-4], "-png"]) # import subprocess
ls = glob.glob( fout_q_pdf[:-4] +"-*.png") # out = subprocess.run(["pdftocairo", fout_q_pdf, fout_q_pdf[:-4], "-png"], capture_output=True, encoding='utf-8')
from slider.convert import pdf2png
fout = pdf2png(fout_q_pdf)
# execute_command(["pdftocairo", fout_q_pdf, fout_q_pdf[:-4], "-png"])
ls = glob.glob( fout)
if len(ls) > 1: if len(ls) > 1:
print("Hacky, two files exist (bad/old png conversaion code", ls) print("Hacky, two files exist (bad/old png conversaion code", ls)
l2 = glob.glob(fout_q_pdf[:-4] + "-000*.png")[0] l2 = glob.glob(fout_q_pdf[:-4] + "-000*.png")[0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment