kapi2289 / vulcan-api

Unofficial UONET+ e-register API
https://vulcan-api.readthedocs.io/
MIT License
72 stars 17 forks source link

`AttributeError: 'NoneType' object has no attribute 'get'` on `klient.oceny()` #14

Closed rrroyal closed 5 years ago

rrroyal commented 5 years ago

When trying to call klient.oceny(), Python 3.7 throws this error:

(...)\site-packages\vulcan\_grade.py", line 27, in from_json
    id = j.get("Id")
AttributeError: 'NoneType' object has no attribute 'get'

When trying to debug this, the problem lies in _vulcan.py file, in oceny(self) function - in the return:

return list(map(lambda x: Ocena.from_json(x), oceny))

The whole ocena object is good, the problem lies in the return statement. Unfortunately, I'm not that experienced in python, so I can't really fix it myself (but I will try anyways :P)

rrroyal commented 5 years ago

Potential fix in #15

kapi2289 commented 5 years ago

Please try to test #16. If still doesn't work, please tell me more details. (vulcan-api version, does Dzienniczek+ app show any grades, etc.)

rrroyal commented 5 years ago

The problem was that Kategoria had the value missing:

{
    "Id": <redacted>,
    "Pozycja": 1,
    "PrzedmiotPozycja": 5,
    "IdPrzedmiot": <redacted>,
    "IdKategoria": 0,
    "Wpis": "<redacted>",
    "Wartosc": <redacted>,
    "WagaModyfikatora": None,
    "WagaOceny": <redacted>,
    "Licznik": None,
    "Mianownik": None,
    "Komentarz": None,
    "Waga": "<redacted>",
    "Opis": "",
    "DataUtworzenia": <redacted>,
    "DataUtworzeniaTekst": "<redacted>",
    "DataModyfikacji": <redacted>,
    "DataModyfikacjiTekst": "<redacted>",
    "IdPracownikD": <redacted>,
    "IdPracownikM": <redacted>,
    "Przedmiot": {
        "Id": <redacted>,
        "Nazwa": "<redacted>",
        "Kod": "<redacted>",
        "Aktywny": True,
        "Pozycja": 1000
    },
    "Kategoria": None, // !!!
    "Pracownik": {
        "Id": 105,
        "Imie": "<redacted>",
        "Nazwisko": "<redacted>",
        "Kod": "<redacted>",
        "Aktywny": True,
        "Nauczyciel": False,
        "LoginId": <redacted>
    }
}

17 should fix it - function returns Ocena object, but before that, it checks if the value exists.

kapi2289 commented 5 years ago

Fixed by #17