Async¶
OpenTamPy contains an async wrapper for each function documented below Note that these don’t increase performance, but simply wrap a function to call them asynchronously
Quick example of the usage of async:
import asyncio
from OpenTamPy import AsyncClient
async def main():
username = "YOURUSERNAME"
password = "YOURPASSWORD"
instance = AsyncClient(username, password)
timetable = await instance.get_timetable()
for lesson in timetable:
print(lesson.courseName)
asyncio.run(main())
- class AsyncClient(username, password, school, debug=False)¶
This is the base class from where you can call all the libraries async functions from. To be able to do this, you need to create an instance of this class first.
- Parameters
username (str) – Your Intranet username. This is only used for authentication purposes
password (str) – Your Intranet password. This is only used for authentication purposes
school (str) – Your schoolcode. Ex:
krmfor MNG,krrfor RGZH. Can be found in the URL. Ex: Inhttps://intranet.tam.ch/krm/, wherekrmwould be the schoolcodedebug (bool) – Whether logging should be set to debug. Defaults to False
- async get_timetable(start_date=0, end_date=0, user_id=None)¶
- Parameters
start_date (int) – Start of the timebracket as ‘DD.MM.YY’, defaults to last monday
end_date – End of the timebracket as ‘DD.MM.YY’, defaults to next sunday
user_id – Fetch timetable for any student with the given Id
timeout (int) – Passed through to the request, increase if you request large amounts of data, as it might take longer to process than the default.
It is possible to fetch someone elses timetable if you only have their studentID, which can be acquired by running get_class_mates. Whether this is intentional or not is unclear, so this might be removed at any time
- Yield
- async get_absences()¶
This function fetches a list of all absences and returns an Iterator containing objects from which you can get information very easily.
instance = Intranet(username, password) absence_iterator = instance.getAbsences() for absence in absence_iterator: print("Name of teacher", absence.Lehrperson)
- Returns
- async get_lesson_absence_data(lesson)¶
This function fetches the absence data corresponding to the
lessonpassed through You can also pass through a list oflessonobjects, and the function will return a list of the corresponding values- Parameters
lesson –
lesson
- async get_class_mates()¶
This function fetches a list of each classMate and yields it back
- Yield
- async get_class_teachers()¶
This function fetches a list of each teacher and yields it back
- Yield
- async set_homework_data(lesson, title, description)¶
- Parameters
- Raises
MissingPermission – Not enough permissions
Set homework data for passed through lesson, returns new homework data
- async delete_homework_info(lesson)¶
- Parameters
lesson – Lesson object for which the absence should be deleted
- Raises
MissingPermission – Not enough permissions
Deletes all homework associated with that lesson