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

updates

parent e10c25ae
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
# beamer-slider
setuptools.setup(
name="coursebox",
version="0.1.13",
version="0.1.15",
author="Tue Herlau",
author_email="tuhe@dtu.dk",
description="A course management system currently used at DTU",
......
Metadata-Version: 2.1
Name: coursebox
Version: 0.1.13
Version: 0.1.15
Summary: A course management system currently used at DTU
Home-page: https://lab.compute.dtu.dk/tuhe/coursebox
Author: Tue Herlau
......
{"profiledFunctions": [{"file": "/home/tuhe/Documents/02465public/pythontools/irlc_box/material/student_files.py", "lineNo": 19, "functionName": "setup_student_files", "profiledLines": []}], "unit": 1e-09}
\ No newline at end of file
{"profiledFunctions": [{"file": "/home/tuhe/Documents/02465public/pythontools/irlc_box/material/student_files.py", "lineNo": 19, "functionName": "setup_student_files", "profiledLines": []}], "unit": 1e-06}
\ No newline at end of file
......@@ -204,24 +204,41 @@ def lectures(info, pensum=None):
l['date'] = d
l['preceded_by_holiday'] = i == holiday
if not continuing_education():
ehw = int(info.get('extraordinary_holiday_week', -1))
if 'extraordinary_holiday_week' in info and int(lecture_info[i]['number']) == int(info['extraordinary_holiday_week']) and ehw == 13:
dow = int(info['day_of_week'])
if dow == 4: # friday
d2 = d + timedelta(days=4) #
l['month'] = d2.strftime('%B')
l['day'] = d2.day
l['date'] = d2
l['extraordinary'] = True
d = d + ow
if i == holiday - 1: d = d + ow
if d.month == 5 and d.day == 8: # grundlovsdag
d += timedelta(days=4)
else:
d = d + timedelta(days=dd[i-0] if i > 1 else 0)
d = d.replace(hour=ice['hour'][i-1], minute=ice['minute'][i-1])
info = lecture_info[i]
ir = info.get('reading', "")
info['reading_long'] = ir.replace("C", "Chapter ") if ir else ""
hwp = info['homework_problems']
info['homework_problems_long'] = hwp.replace("P", "Problem ") if hwp else ""
if info["learning_objectives"]:
info["learning_objectives"] = [s.strip() for s in info["learning_objectives"].split("\n")]
l.update(info)
linfo = lecture_info[i]
ir = linfo.get('reading', "")
linfo['reading_long'] = ir.replace("C", "Chapter ") if ir else ""
hwp = linfo['homework_problems']
linfo['homework_problems_long'] = hwp.replace("P", "Problem ") if hwp else ""
if linfo["learning_objectives"]:
linfo["learning_objectives"] = [s.strip() for s in linfo["learning_objectives"].split("\n")]
l.update(linfo)
lectures.append(l)
return lectures, pensum
......@@ -255,7 +272,6 @@ def class_information():
continuing_education_mode = core_conf['continuing_education_mode']
faq = xlsx_to_dicts(paths['information.xlsx'], sheet='faq')
d = {'year': year(),
'piazza': piazza, # deprecated.
'course_number': course_number,
......@@ -300,19 +316,8 @@ def class_information():
for cmd, aux, display in zip(ls(gi['tex_command']), ls(gi['tex_aux']), ls(gi['tex_display'])):
cm = dict(command=cmd, aux=get_aux(paths['02450public'] + "/"+aux), output=display)
cmds.append(cm)
# ax = parse_aux(aux, bibtex=gi['bibtex'])
# for k in ax:
# ax[k]['pyref'] = display % (ax[k]['nicelabel'],)
# newref[cmd] = ax
d['references'] = dict(bibtex=bibtex, commands=cmds)
# references = dict(bibtex=bibtex,
# # aux=auxfile,
# commands=[dict(command='\\aref2', output="(Assignment 2, %s)", aux=auxfile),
# dict(command='\\nref', output="\cite[%s]{herlau}", aux=auxfile),
# ])
else:
print("[info]", "No bibtex rereferences specified. Check configuration file. ")
......@@ -350,6 +355,29 @@ def class_information():
d['teams'] = xlsx_to_dicts(paths['information.xlsx'], sheet='teams')
fix_instructor_comma(d['teams'], d['instructors'])
if 'reports_delta' in d:
print(234)
if 'handin_day_delta' in d:
d['reports_info'] = {}
for k, r in enumerate(d['reports_handin']):
ri = {}
d['reports_info'][r] = ri
# print(d['lectures'][r-1]['date'], r)
nd = d['lectures'][r-1]['date'] + timedelta(days=int(d['handin_day_delta']))
ri['date'] = nd
ri['html'] = f"{nd.day} {nd.strftime('%b')}"
ab = 'st'
if nd.day == 2:
ab = "nd"
elif nd.day == 3:
ab = 'rd'
elif nd.day >= 4:
ab = 'th'
ri['latex_long'] = f"{nd.strftime('%A')} {nd.day}{ab} {nd.strftime('%B')}, {nd.year}"
ri['latex_short'] = f"{nd.strftime('%B')} {nd.day}{ab}, {nd.year}"
d['reports_info'][k] = ri
return d
def fix_instructor_comma(dd, instructors):
......
......@@ -311,7 +311,7 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil
if rel not in target or target[rel]['hash'] != source[rel]['hash']:
_ensure_target_dir_exists( output_dir + "/" + rel)
print(" -> ", output_dir + "/" + rel)
print("[fix shared] -> ", output_dir + "/" + rel)
shutil.copy(shared_base +"/" + rel, output_dir + "/" + rel)
target[rel] = source[rel].copy()
target[rel]['modified'] = True
......@@ -332,115 +332,6 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil
with open(output_dir + "/sharedcache.pkl", 'wb') as f:
pickle.dump(target, f)
print("fix_shared()", time.time() - t0)
#
# if pdf2png:
# if f.endswith(".pdf") and pdf2png:
# if verbose:
# print("converting to png", f)
# convert.pdf2png(of)
#
# for f in source:
# if f not in target:
# print(f)
# else:
# if source[f]['hash'] != target[f]['hash']:
# print(f, f)
#
#
#
# a = 234
# # if rel not in source:
#
# # source[rel] = dict(mtime=os.path.getmtime(f), hash=hash_file_(f))
# #
#
#
# # Everything has a hash/mtime that is up to date. Now look at target dir
#
# get_cache_from_dir(output_dir)
#
# # Get the corresponding output at destination:
#
#
#
#
#
#
# for path in Path(shared_base).rglob('*'):
# print(path)
# a = 234
# def rec_fix_shared(shared_base, output_dir):
# if dosvg:
# for svg in glob.glob(shared_base+"/*.svg"):
# # if not os.path.exists(shared_base + )
# if not cache_contains_file(cache_base, svg):
# # if verbose:
# print("converting to pdf", svg)
# svg2pdf(svg,crop=True, text_to_path=True)
# cache_update_file(cache_base, svg)
# assert False
#
# files = glob.glob(shared_base+"/*")
# for f in files:
# if f.endswith("cache.pkl"):
# continue
#
# if "templates" in f and f.endswith("_partial.tex"):
# continue
#
# if os.path.isdir(f):
# od2 = output_dir + "/" + os.path.basename(f)
# if not os.path.exists(od2):
# os.mkdir(od2)
# rec_fix_shared(f, od2)
# else:
# of = output_dir + "/" + os.path.basename(f)
# if not os.path.exists(of) or not filecmp.cmp(f, of,shallow=shallow):
# print(f"> fix_shared() -> {of}")
# shutil.copy(f, of)
# if f.endswith(".pdf") and pdf2png:
# if verbose:
# print("converting to png", f)
# convert.pdf2png(of)
# # cache_update_file(cache_base, f)
#
# if verbose:
# print(" done!")
# if pdf2png:
# assert False
# get diff.
# directory_cmp = filecmp.dircmp(a=paths['shared'], b=output_dir)
# from filecmp import dircmp
# from filecmp import dircmp
# def print_diff_files(dcmp):
# for name in dcmp.diff_files:
# print("diff_file %s found in %s and %s" % (name, dcmp.left, dcmp.right))
# print("")
# for sub_dcmp in dcmp.subdirs.values():
# print_diff_files(sub_dcmp)
#
# t0 = time.time()
# dcmp = dircmp(paths['shared'], output_dir)
# print_diff_files(dcmp)
# print("dircmp", time.time() - t0)
# directory_cmp.report()
# import time
# t0 = time.time()
# rec_fix_shared(shared_base=paths['shared'], output_dir=output_dir)
# import time
# # import dirsync
# # dirsync.sync(paths['shared'], output_dir, 'diff')
# print("mine", time.time() - t0)
a = 234
def jinjafy_shared_templates_dir(paths, info):
tpd = paths['shared'] + "/templates"
......@@ -556,24 +447,30 @@ def mvfiles(source_dir, dest_dir):
shutil.copy(full_file_name, os.path.dirname(dest_dir))
# @profile
def make_webpage(dosvg=True):
def make_webpage(dosvg=True, upload=True):
cinfo = class_information()
paths = get_paths()
fix_shared(paths, output_dir=os.path.dirname(paths['homepage_out']), pdf2png=True, dosvg=dosvg)
wdir = paths['homepage_template']
jinjafy_template(cinfo, file_in=wdir, file_out=paths['homepage_out'])
print("Instructors for course: ")
s = ""
for dex,i in enumerate(cinfo['instructors']):
if dex > 0:
s += "; "
s += i['email']
cinfo['instructors'][dex]['ok'] = i['email'] not in [t['email'] for t in cinfo['teachers'] ]
jinjafy_template(cinfo, file_in=wdir, file_out=paths['homepage_out'])
blrb = os.path.dirname(paths['homepage_template']) +"/homepage_widget_blurb_template.html"
if os.path.exists( blrb):
jinjafy_template(cinfo, file_in=blrb, file_out=blrb.replace("_template.html", ".html"))
print(s)
if upload:
import subprocess
cmd = f"cd {os.path.dirname(paths['homepage_template'] )} && rsync --delete --rsh=ssh -av ./ tuhe@thinlinc.compute.dtu.dk:/www/docs/courses/02465/"
subprocess.run([cmd], shell=True)
# This should probably be moved into jinjafy
def tt(value):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment