kapi2289 / vulcan-api

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

Secondname must be class str, got None that is a class NoneType. #55

Closed Rei-x closed 3 years ago

Rei-x commented 3 years ago

Like in title, I get TypeError when I'm trying to select student using vulcan hebe api.

TypeError: ("'second_name' must be (<class 'str'>,) (got None that is a <class 'NoneType'>)."

Antoni-Czaplicki commented 3 years ago

Please send me your code

Rei-x commented 3 years ago
async def main():
    keystore_manager = KeystoreFileManager("keystore.json")
    account_manager = AccountFileManager("account.json")

    if not account_manager.account:
        await account_manager.register_and_save(keystore_manager.key, "myToken", "mySymbol", "myPin")

    client = VulcanHebe(keystore_manager.key, account_manager.account)

    await client.select_student()

    await client.close()

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

KeystoreFileManager and AccountFileManager are simple classes for json file handling. You can see all of the code here.

Antoni-Czaplicki commented 3 years ago

Can you try seeing if #56 fixes your problem?

Rei-x commented 3 years ago

56 still doesn't fix my problem, there is full console log from this error: click

edit. This is what printed out, when I added line in photo (I replaced my private data with xyz): {'Id': XYZ, 'Value': 'xyz@gmail.com', 'FirstName': 'xyz', 'SecondName': None, 'Surname': 'xyz', 'DisplayName': 'xyz', 'LoginRole': 'Uczen'}

It seems like API returns None value and related package cannot convert it to string, so it shows up error.

image

Antoni-Czaplicki commented 3 years ago

Yes, probably the easiest (but I'm not sure if the best) option is to replace second_name: str = StringField(key="SecondName", required=False) by second_name: str = StringField(key="SecondName", default=""), please try this and give me a feedback.

Rei-x commented 3 years ago

Nevermind, I installed new version of vulcan-api in wrong virtual environment, now everything works perfectly with #56, thank you so much for help, again!