- Python 100%
| src/campusnet | Emit warning when skipping a table row due to unexpected format | |
| .gitignore | Create Python Package | |
| LICENSE | Create Python Package | |
| pyproject.toml | Emit warning when skipping a table row due to unexpected format | |
| README.md | Update README.md | |
| uv.lock | Add uv.lock | |
CampusNet Python
Scope of this project
This project is a fork of https://github.com/TINF21CS1/python-campusnet , tweaked to work with TU Dresden selma.
It's developed for the authors personal needs and fun, of course. If you'd like to fetch data from selma / CampusNet that's currently not retrieved, feel free to open an issue or PR for it.
This tool is used with and tested for TU Dresden selma, it may or may not work with CampusNet instances at other universities. This should not stop you from trying!
Installation
pipx install git+https://codeberg.org/gdstr/python-campusnet.git
For using the watch or notify functionality, the author recommends the use of a systemd user unit.
[Unit]
Description=Campusnet exam results notifier
After=graphical-session.target network-online.target
[Service]
ExecStart=/home/$USER/.local/bin/campusnet -b 'https://selma.tu-dresden.de' -u $LOGIN -p $PATH_TO_PASSWORD_IN_PASSWORDSTORE watch --endpoints EXAMREGISTRATION EXAMRESULTS CREATEDOCUMENT
[Install]
WantedBy=graphical-session.target network-online.target
Place the above in ~/.config/systemd/user/campusnet.service while replacing
- $USER with the username on your system (if you havent't installed python-campusnet via pipx, the location of the executable may differ),
- $LOGIN with your ZIH user login,
- $PATH_TO_PASSWORD_IN_PASSWORDSTORE with the pass[wordstore] path to the password for the ZIH login.
# Make systemd discover the new unit
systemctl --user daemon-reload
# Enable and start the unit
systemd --user enable --now campusnet.service
In case the OpenPGP private key for the passwordstore isn't unlocked yet, it will most likely show some kind of pinentry.
# Watch the logs
journalctl --user -fu campusnet.service
Usage Examples
These are some examples for using the original ("old") APIs.
Examples for using the new ones may be added in the future.
In the meantime it's recommended to use campusnet --help (note the output below is outdated) or taking a look in the source for information on the Python API.
Getting Exams and Grades directly
The module can be used directly to get information about all exams.
$ campusnet --help
usage: campusnet [-h] [-b BASE_URL] [-o {table,json,csv}] username [password]
Get exams from CampusNet instance.
positional arguments:
username Username (including domain)
password Password (will be read from stdin if not supplied)
optional arguments:
-h, --help show this help message and exit
-b BASE_URL, --base-url BASE_URL
Base URL of the CampusNet instance (default: https://dualis.dhbw.de/)
-o {table,json,csv}, --output {table,json,csv}
Output format of the data (default: table)
$ campusnet s*******@student.dhbw-mannheim.de --base-url https://dualis.dhbw.de
Password:
Module Name Exam Semester Description Grade
--------- ---------------------------------------- ------------------------------------------------------ ------------ -------------------------------------------- -------
T3_1000 Praxisprojekt I T3_1000.1 Projektarbeit 1 (MA-TINF21CS1) SoSe 2022 Projektarbeit (1%)
T3_1000 Praxisprojekt I T3_1000.2 Wissenschaftliches Arbeiten 1 (MA-TINF21CS1) SoSe 2022 Ablauf- und Reflexionsbericht (1%)
T3INF1001 Mathematik I T3INF1001.1 Lineare Algebra (MA-TINF21CS1) WiSe 2021/22 Klausurarbeit (50%) *.*
T3INF1001 Mathematik I T3INF1001.2 Analysis (MA-TINF21CS1) SoSe 2022 Klausurarbeit (50%) *.*
T3INF1002 Theoretische Informatik I (MA-TINF21CS1) Modulabschlussleistungen SoSe 2022 Klausurarbeit (100%)
T3INF1003 Theoretische Informatik II Modulabschlussleistungen SoSe 2022 Klausurarbeit (100%)
T3INF1004 Programmieren Modulabschlussleistungen SoSe 2022 Programmentwurf (100%)
T3INF1005 Schlüsselqualifikationen Modulabschlussleistungen SoSe 2022 Klausurarbeit (< 50 %) (100%)
T3INF4102 Einführung in die Kryptologie Modulabschlussleistungen SoSe 2022 Klausur 75 % und Laborarbeit 25 % (100%)
T3INF9000 Web and App Engineering Modulabschlussleistungen SoSe 2022 Klausur 50 % und Programmentwurf 50 % (100%)
T3INF1006 Technische Informatik I Modulabschlussleistungen WiSe 2021/22 Klausurarbeit (100%) *.*
T3INF9001 Cyber Security Basics Modulabschlussleistungen WiSe 2021/22 Hausarbeit (100%) *.*
```--------------------------------------- ---
Python package
You can also use campusnet as a package to interact with CampusNet from Python.
$ python
>>> from campusnet import CampusNetSession
>>> s = CampusNetSession("s***REMOVED***@student.dhbw-mannheim.de", "***REMOVED***")
>>> s.modules
[Module(num='T3_1000', name='Praxisprojekt I', credits=20.0, status='', semesters=['SoSe 2022'], id='381683598069776', grade=None), Module(num='T3INF1001', name='Mathematik I', credits=8.0, status='', semesters=['SoSe 2022', 'WiSe 2021/22'], id='380685560144022', grade=None), Module(num='T3INF1002', name='Theoretische Informatik I (MA-TINF21CS1)', credits=5.0, status='', semesters=['SoSe 2022'], id='382855008624547', grade=None), Module(num='T3INF1003', name='Theoretische Informatik II', credits=5.0, status='', semesters=['SoSe 2022'], id='382214102615788', grade=None), Module(num='T3INF1004', name='Programmieren', credits=9.0, status='', semesters=['SoSe 2022'], id='379974839816701', grade=None), Module(num='T3INF1005', name='Schlüsselqualifikationen', credits=5.0, status='', semesters=['SoSe 2022'], id='379974840574866', grade=None), Module(num='T3INF4102', name='Einführung in die Kryptologie', credits=5.0, status='', semesters=['SoSe 2022'], id='382214104541196', grade=None), Module(num='T3INF9000', name='Web and App Engineering', credits=5.0, status='', semesters=['SoSe 2022'], id='379974842066225', grade=None), Module(num='T3INF1006', name='Technische Informatik I', credits=5.0, status='bestanden', semesters=['WiSe 2021/22'], id='380703425164844', grade=1.2), Module(num='T3INF9001', name='Cyber Security Basics', credits=3.0, status='bestanden', semesters=['WiSe 2021/22'], id='379974841329087', grade=1.6)]
>>> s.get_exams_for_module(s.modules[9])
[Exam(semester='WiSe 2021/22', description='Hausarbeit (100%)', grade=1.6)]