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: krm for MNG, krr for RGZH. Can be found in the URL. Ex: In https://intranet.tam.ch/krm/, where krm would be the schoolcode

  • debug (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

lesson

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

absence

async get_lesson_absence_data(lesson)

This function fetches the absence data corresponding to the lesson passed through You can also pass through a list of lesson objects, and the function will return a list of the corresponding values

Parameters

lessonlesson

async get_class_mates()

This function fetches a list of each classMate and yields it back

Yield

ClassMate

async get_class_teachers()

This function fetches a list of each teacher and yields it back

Yield

teacher

async set_homework_data(lesson, title, description)
Parameters
  • title (str) – Title for absence to be set

  • description (str) – Description for absence to be set

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