Пример #1
0
 def track(self, record):
     with external_call(
         self.rest_client, error_message="Statistics unavailable"
     ) as client:
         asyncio.new_event_loop().run_until_complete(
             client.track_event(record.ip, record.event_type, self.api_token)
         )
Пример #2
0
async def get_group_schedule(
    client: GroupScheduleRestClient, from_date: str, to_date: str, group: str, **kwargs
):
    with external_call(client) as rest_client:
        data, status = await rest_client.schedule(
            from_date=from_date, to_date=to_date, value=group
        )
    return parse(data), status
Пример #3
0
async def get_all_groups(client: GroupRestClient,
                         query: Optional[str] = None,
                         faculty: Optional[int] = None,
                         **kwargs):
    with external_call(client) as rest_client:
        data, status = await rest_client.all_groups(query=query,
                                                    faculty=faculty)
    return data["suggestions"], status
Пример #4
0
async def is_group_exists(client: GroupRestClient,
                          group: str,
                          faculty: Optional[int] = None,
                          **kwargs):
    with external_call(client) as rest_client:
        data, status = await rest_client.exists(group_code=group,
                                                faculty=faculty)
    return data, status
Пример #5
0
async def get_all_teachers(
    client: TeachersRestClient,
    faculty: Optional[int] = None,
    query: Optional[str] = None,
    **kwargs
):
    with external_call(client) as rest_client:
        data, status = await rest_client.all_teachers(faculty=faculty, query=query)
    return data["suggestions"], status
Пример #6
0
async def is_teacher_exists(
    client: TeachersRestClient,
    faculty: Optional[int] = None,
    teacher: Optional[str] = None,
    **kwargs
):
    with external_call(client) as rest_client:
        data, status = await rest_client.exists(faculty=faculty, teacher=teacher)
    return data, status
Пример #7
0
async def is_faculty_exists(client: FacultiesRestClient, query: str, **kwargs):
    with external_call(client) as rest_client:
        data, status = await rest_client.all_faculties(**kwargs)

    exists = False
    for faculty in parse_faculties(data):
        if query in faculty["name"]:
            exists = True
            break
    return {"exists": exists}, status
Пример #8
0
async def get_all_faculties(client: FacultiesRestClient, **kwargs):
    with external_call(client) as rest_client:
        data, status = await rest_client.all_faculties(**kwargs)
    return parse_faculties(data), status