diff --git a/requirements.txt b/requirements.txt index 6391557b63d1ab62ba736a14ee842e51fb2623a9..14848f0c4fca9691de3b0c52c412881e784c96d8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ pexpect matplotlib numpy pycode_similar -jinjafy +# jinjafy beamer-slider tinydb +python-gitlab diff --git a/setup.py b/setup.py index 94d0444c9c8dfc356e7501cade1b10b981a62b16..6c26e5368975471a983736973cc710277f696718 100644 --- a/setup.py +++ b/setup.py @@ -4,18 +4,16 @@ """ Windows> py -m build && twine upload dist/* Linux> python -m build && python -m twine upload dist/* - """ import setuptools -import pkg_resources with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() -# beamer-slider + setuptools.setup( name="coursebox", - version="0.1.18.13", + version="0.1.18.20", author="Tue Herlau", author_email="tuhe@dtu.dk", description="A course management system currently used at DTU", @@ -34,5 +32,6 @@ setuptools.setup( package_dir={"": "src"}, packages=setuptools.find_packages(where="src"), python_requires=">=3.8", - install_requires=['numpy','pycode_similar','tika','openpyxl', 'xlwings','matplotlib','langdetect','beamer-slider','tinydb'], + install_requires=['numpy','pycode_similar','tika','openpyxl', 'xlwings','matplotlib','langdetect', + 'beamer-slider','tinydb', 'python-gitlab'], ) diff --git a/src/coursebox.egg-info/PKG-INFO b/src/coursebox.egg-info/PKG-INFO index 635ffde4e5000fc583e16c1796e80cc57626def8..ceb4f447391d8c28f7a18fc1dfbf5214576e4337 100644 --- a/src/coursebox.egg-info/PKG-INFO +++ b/src/coursebox.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: coursebox -Version: 0.1.18.13 +Version: 0.1.18.19 Summary: A course management system currently used at DTU Home-page: https://lab.compute.dtu.dk/tuhe/coursebox Author: Tue Herlau diff --git a/src/coursebox.egg-info/requires.txt b/src/coursebox.egg-info/requires.txt index 0a856679d9bb3a3f9529383f867a9815d6a73cfa..7e1958daaf7510e2eedfb0f27a54e6f7793ca58c 100644 --- a/src/coursebox.egg-info/requires.txt +++ b/src/coursebox.egg-info/requires.txt @@ -7,3 +7,4 @@ matplotlib langdetect beamer-slider tinydb +python-gitlab diff --git a/src/coursebox/admin/gitlab.py b/src/coursebox/admin/gitlab.py index 159d589785e3a19db00ec769b89ebc92d2e1963f..b406f709d10a1a8d56944a85055edd03e9c4051e 100644 --- a/src/coursebox/admin/gitlab.py +++ b/src/coursebox/admin/gitlab.py @@ -1,3 +1,5 @@ +import datetime + import gitlab import gitlab.const from urllib.parse import urlparse @@ -27,17 +29,24 @@ def sync_tas_with_git(): for i in p.invitations.list(): print("Invited", i.invite_email.split("@")) - if False: - inv = p.invitations.create({ - "email": "fmry@dtu.dk", - "access_level": gitlab.const.AccessLevel.MAINTAINER, - }) - inv.save() + if True: + for i in info['instructors']: + # i = info['instructors'][2] + if i['email'].split("@")[0].strip() in all_tas: + print("TA found already", i['name'], i['email']) + else: + import datetime + expires = datetime.datetime.now() + datetime.timedelta(days=30*5+14) + expires_str =expires.strftime('%A %b %d, %Y at %H:%M GMT') + + inv = p.invitations.create({ + "email": i['email'], # '"fmry@dtu.dk", + "access_level": gitlab.const.AccessLevel.MAINTAINER, + "expires_at": expires_str, + }) + inv.save() + print("Inviting...", i['email'], i['name']) - # - # - # - # # for p in gl.projects.list(iterator=True): # prs.append(p) # for p in prs: diff --git a/src/coursebox/core/info.py b/src/coursebox/core/info.py index efe3a417bbf1ba09cd85da12b7db8dd7a78f16a9..ae0efee3cc790faa5d14a91d0a3e70f40aef4ed7 100644 --- a/src/coursebox/core/info.py +++ b/src/coursebox/core/info.py @@ -429,7 +429,7 @@ def class_information(verbose=False, if 'id' in r: d['reports'][r['id']] = r r['handin'] = get_lecture_date(r['handin'], delta_days=int(d['handin_day_delta'])) - r['handout'] = get_lecture_date(r['handout'], delta_days=0) + r['handout'] = get_lecture_date(r['handout'], delta_days=int(d.get('handout_day_delta', 0))) r['exercises'] = [e.strip() for e in r['exercises'].split(",") if len(e.strip()) > 0] ice = xlsx_to_dicts(paths['information.xlsx'], sheet='ce', as_dict_list=True) @@ -495,7 +495,7 @@ def _save_info_cache(): known[id] = f"s{len(known):6d}".replace(" ", "0") d = d.replace(id, known[id]) elif isinstance(d, dict): - for k, v in d.items(): + for k, v in d.copy().items(): d[_remove_ids(k)] = _remove_ids(v) elif isinstance(d, list): d = [_remove_ids(k) for k in d] diff --git a/src/coursebox/core/info_paths.py b/src/coursebox/core/info_paths.py index a775779caf87f1256dd564b0b2e5d7d0bf465609..cc07d6e417b99b899a7998665e1e8fe4594881e4 100644 --- a/src/coursebox/core/info_paths.py +++ b/src/coursebox/core/info_paths.py @@ -72,6 +72,9 @@ def get_paths(): if not os.path.isdir(paths['book']): paths['book'] = root_02450public + "/Notes/Latex" + # if 'book' in paths and os.path.isdir(paths['book']): + # pass + if os.path.exists(os.path.dirname(paths['instructor_project_evaluations'])): if not os.path.isdir(paths['instructor_project_evaluations']): os.mkdir(paths['instructor_project_evaluations']) diff --git a/src/coursebox/material/homepage_lectures_exercises.py b/src/coursebox/material/homepage_lectures_exercises.py index 7206669f1caa23812ddf854b2aad95a98ea37fe5..727363b32117a66308087745b71c6c7e5a3a4049 100644 --- a/src/coursebox/material/homepage_lectures_exercises.py +++ b/src/coursebox/material/homepage_lectures_exercises.py @@ -92,11 +92,16 @@ def make_lectures(week=None, mode=0, gather_pdf_out=True, gather_sixup=True, mak mode = HANDOUT = 2: version handed out to students. """ assert mode in [PRESENTATION, NOTES, HANDOUT] - paths = get_paths() + info = class_information() + if 'lecture_notes_tex' in info: + book_pdf = paths['02450public'] + "/" + info['lecture_notes_tex'][:-4] + ".pdf" + else: + book_pdf = paths['book'] + "/02002_Notes.pdf" + if os.path.exists(paths['book']): book_frontpage_png = paths['shared']+"/figures/book.png" #paths['lectures']+"/static/book.png" - slide_to_image(paths['book'] + "/02450_Book.pdf", book_frontpage_png, page_to_take=1) + slide_to_image(book_pdf, book_frontpage_png, page_to_take=1) shutil.copy(paths['book'] + "/book_preamble.tex", paths['shared']) info = class_information() jinjafy_shared_templates_dir(paths, info) # Compile templates in shared/templates @@ -389,10 +394,12 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil # update_source_cache = False source_extra = {} for rel in source: - if rel.endswith(".svg") and source[rel]['modified'] and dosvg: - pdf_file = svg2pdf(shared_base + "/"+rel, crop=True, text_to_path=True) - rel = os.path.relpath(pdf_file, shared_base) - source_extra[rel] = dict(mtime=os.path.getmtime(pdf_file), hash=hash_file_(pdf_file), modified=True) + if rel.endswith(".svg"): + pdf_ = shared_base + "/"+rel[:-4] + ".pdf" + if (source[rel]['modified'] or not os.path.isfile(pdf_)) and dosvg: + pdf_file = svg2pdf(shared_base + "/"+rel, crop=True, text_to_path=True) + rel = os.path.relpath(pdf_file, shared_base) + source_extra[rel] = dict(mtime=os.path.getmtime(pdf_file), hash=hash_file_(pdf_file), modified=True) for k, v in source_extra.items(): source[k] = v @@ -415,12 +422,14 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil if pdf2png: for rel in target: - if rel.endswith(".pdf") and target[rel]['modified']: - # print("pdf2png: ") - png = convert.pdf2png(output_dir + "/" + rel, verbose=True) - target[rel]['modified'] = False - target[rel]['hash'] = hash_file_(output_dir + "/" + rel) - target[rel]['mtime'] = os.path.getmtime(output_dir + "/" + rel) + if rel.endswith(".pdf"): + png_target = output_dir + "/" + rel[:-4] + ".png" + if target[rel]['modified'] or not os.path.isfile(png_target): + # print("pdf2png: ") + png = convert.pdf2png(output_dir + "/" + rel, verbose=True) + target[rel]['modified'] = False + target[rel]['hash'] = hash_file_(output_dir + "/" + rel) + target[rel]['mtime'] = os.path.getmtime(output_dir + "/" + rel) with open(shared_base + "/sharedcache.pkl", 'wb') as f: pickle.dump(source, f)