Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception getting punishments #312

Open
ioull opened this issue Oct 4, 2024 · 0 comments
Open

Exception getting punishments #312

ioull opened this issue Oct 4, 2024 · 0 comments

Comments

@ioull
Copy link

ioull commented Oct 4, 2024

I try to get the punishments with this code :

 import pronotepy
from pronotepy.ent import occitanie_toulouse_edu

client = pronotepy.ParentClient('https://0312744p.index-education.net/pronote/parent.html',
                          username='XXXXXXXX',
                          password='XXXXXXXX',
                          ent=occitanie_toulouse_edu)

if client.logged_in: # check if client successfully logged in
    # get the all the periods (may return multiple types like trimesters and semesters but it doesn't really matter
    # the api will get it anyway)
    periods = client.periods

    for period in periods:
        for punishment in period.punishments:
            print(punishment)

And I got this exception :

Traceback (most recent call last):
  File "/services/pronote2rest/dev/myvenv2/lib/python3.11/site-packages/pronotepy/dataClasses.py", line 220, in __call__
    json_value = json_value[p]
                 ~~~~~~~~~~^^^
KeyError: 'travailAFaire'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/services/pronote2rest/dev/test.py", line 17, in <module>
    for punishment in period.punishments:
                      ^^^^^^^^^^^^^^^^^^
  File "/services/pronote2rest/dev/myvenv2/lib/python3.11/site-packages/pronotepy/dataClasses.py", line 641, in punishments
    return [Punishment(self._client, a) for a in absences if a["G"] == 41]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/services/pronote2rest/dev/myvenv2/lib/python3.11/site-packages/pronotepy/dataClasses.py", line 641, in <listcomp>
    return [Punishment(self._client, a) for a in absences if a["G"] == 41]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/services/pronote2rest/dev/myvenv2/lib/python3.11/site-packages/pronotepy/dataClasses.py", line 2074, in __init__
    self.homework: str = self._resolver(str, "travailAFaire")
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/services/pronote2rest/dev/myvenv2/lib/python3.11/site-packages/pronotepy/dataClasses.py", line 234, in __call__
    raise ParsingError(
pronotepy.exceptions.ParsingError: Could not follow path

Here is how the punishment looks like in pronote :
image

It seems that there is no 'TravailAFaire'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant