bain3 / pronotepy

A python API wrapper for pronote
MIT License
191 stars 55 forks source link

logging in hangs intermittently #142

Closed vingerha closed 1 year ago

vingerha commented 2 years ago

Using v2.5.0 but also noticed this in v2.4.0

My setup :

Recently I have seen that the logging in 'hangs' often at 8 or 9 in the morning but ystd also at 19:00, i.e. it shows me this in the log and then 'nothing' after...hangs forever image

Now, when I restart the process all goes fine again and the next x runs have no issue...until it suddenly stops connecting From what I could identify, it hangs in this part of pronoteAPI (get.repsonse seems to block??)

On the basis that I am not really known to rsa etc...apologies for not asking the right questions Q1: as my process is a continuous one, should I possibly delete cookies after each (hourly) run? Q2: I once received an error on MR not being set/available...would this help if I provide more info Q3: might the container/image OS have something to do with this? ...any other ideas you have?


        # get rsa keys and session id
        log.debug(f"Requesing html: {self.root_site}/{self.html_page}")
        get_response = self.session.request(
            "GET",
            f"{self.root_site}/{self.html_page}",
            headers=headers,
            cookies=self.cookies,
        )
        self.attributes = self._parse_html(get_response.content)
        # uuid
        self.encryption.rsa_keys = {
            "MR": self.attributes["MR"],
            "ER": self.attributes["ER"],
        }
        uuid = base64.b64encode(
            self.encryption.rsa_encrypt(self.encryption.aes_iv_temp)
        ).decode()
        # post
        json_post = {"Uuid": uuid, "identifiantNav": None}
        self.encrypt_requests = not self.attributes.get("sCrA", False)
        self.compress_requests = not self.attributes.get("sCoA", False)
Bapt5 commented 2 years ago

Hello What error is causing the program to crash? And is it always the same error that makes the program crash? If the error is KeyError: MR then I know the problem and I have already got it with an app like yours. It is very hard to reproduce because it is very rare and I think that it comes from a bug in Pronote itself.

vingerha commented 2 years ago

Until now, from what I have seen, in almost all cases it just hangs with the last line as in above screenshot, ... how could I increase logging for pronotepy? Once (only once) I had below error, it crashed and then waited for the next run and then again...stopped with above line. And here indeed... it is very rare as you already wrote but it started happening recently (last 2 weeks or so). Since my setup is a container and I did not change it wrt to the OS, I cannot blame it on the OS of that as well I guess

    client = pronotepy.Client('https://'+prefix_url+'.index-education.net/pronote/eleve.html', username, password, _ent)
  File "/usr/local/lib/python3.9/site-packages/pronotepy/clients.py", line 290, in __init__
    super().__init__(pronote_url, username, password, ent)
  File "/usr/local/lib/python3.9/site-packages/pronotepy/clients.py", line 59, in __init__
    self.attributes, self.func_options = self.communication.initialise()
  File "/usr/local/lib/python3.9/site-packages/pronotepy/pronoteAPI.py", line 69, in initialise
    self.encryption.rsa_keys = {'MR': self.attributes['MR'], 'ER': self.attributes['ER']}
KeyError: 'MR'
Bapt5 commented 2 years ago

Okay so the problem coming from Pronote I think the best thing to do is to use a try: except: to connect another time if it didn't work. I'll try to find out where the problem is coming from to see if we can fix it.

vingerha commented 2 years ago

update, this morning it ran fine 6+7+8 and now it hangs since 9. I will keep it hanging till late afternoon and see if eventually something happens...then I will restart again. Since I have a separate setup, I can modify the code locally and keep testing, please also let me know if I can increase logging info.

Bapt5 commented 2 years ago

Can you add the line

log.debug(f"Html response: {get_response.content}")

to line 74 of pronoteAPI.py please and send me the result.

vingerha commented 2 years ago

I am only adding the part for my first child, that is at least where it was hanging before. I tried to obfuscate a bit with lots of 000 as not sure if what I am sharing can be re-used. Error seems to indicate cache issue but it returns the 'same' with each run also when it connects and collects data

EDIT: for my second child, the same error is thrown and he connects to a different school and different CAS/ENT


2022-06-21 13:10:31,521 DEBUG Html response: b'<!DOCTYPE html>\r\n<html lang="fr" xmlns="http://www.w3.org/1999/xhtml">\r\n <head>\r\n <base target="_blank" />\r\n <meta http-equiv="X-UA-Compatible" content="IE=edge" />\r\n <meta http-equiv="expires" content="0"/>\r\n <meta http-equiv="pragma" content="no-cache"/>\r\n <meta http-equiv="cache-control" content="no-cache"/>\r\n <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" />\r\n <title>CENTRE INTERNATIONAL VALBONNE - PRONOTE</title>\r\n <meta name="DC.title" content="CENTRE INTERNATIONAL VALBONNE - PRONOTE" />\r\n <meta name="description" content="PRONOTE Espace \xc3\x89l\xc3\xa8ves - CENTRE INTERNATIONAL VALBONNE - VALBONNE (006) - gestion des notes, absences, punitions, cahier de textes pour les \xc3\xa9tablissements scolaires." />\r\n <meta name="DC.description" content="PRONOTE Espace \xc3\x89l\xc3\xa8ves - CENTRE INTERNATIONAL VALBONNE - VALBONNE (006) - gestion des notes, absences, punitions, cahier de textes pour les \xc3\xa9tablissements scolaires." />\r\n <meta name="DC.creator" content="CENTRE INTERNATIONAL VALBONNE" />\r\n <meta name="DC.publisher" content="PRONOTE" />\r\n <meta name="DC.coverage" content="VALBONNE (006)" />\r\n <meta name="geo.placename" content="VALBONNE (006)" />\r\n <meta name="robots" content="index" />\r\n <link rel="apple-touch-icon" sizes="180x180" href="./images/apple-touch-icon.png" />\r\n <link rel="icon" type="image/png" href="./images/favicon-32x32.png" sizes="32x32" />\r\n <link rel="icon" type="image/png" href="./images/favicon-16x16.png" sizes="16x16" />\r\n <link rel="manifest" href="./images/manifest.json" />\r\n <link rel="mask-icon" sizes="any" href="./images/favicon.svg" color="#22874b">\r\n <meta name="apple-mobile-web-app-title" content="PRONOTE" />\r\n <meta name="msapplication-config" content="./images/browserconfig.xml" />\r\n <meta name="application-name" content="PRONOTE" />\r\n <meta name="msapplication-TileColor" content="#22874b" />\r\n <meta name="msapplication-TileImage" content="./images/mstile-144x144.png" />\r\n <meta name="theme-color" content="#22874b" />\r\n<link rel="stylesheet" type="text/css" href="E_3_C_A1B185F4C3F8EF6211F891EE90EEE10000000000000000000000000000000000_L_1036/espace/css/eleve.css"/>\r\n<script type="text/javascript" src="E_3_C_CE69612D5DB7B290A235FC788E28850000000000000000000000000000000000_L_1036/eleve_ext.js"></script>\r\n<script type="text/javascript" src="E_3_C_C8A4E8CB632E941221705BAD738D650000000000000000000000000000000000_L_1036/traductions.js"></script>\r\n<script type="text/javascript" src="E_3_C_4132B917A5A0A1609FB01F9202F6940000000000000000000000000000000000_L_1036/imagesconnexion.js"></script>\r\n<script type="text/javascript" src="E_3_C_3DD8924A931800223557BA4BC76DFB6000000000000000000000000000000000_L_1036/eleve.js"></script>\r\n<script type="text/javascript">\r\nrequire(\'deferLoadingScript.js\').add (\'jspdf\', [\'E_3_C_D9F97D890939B22C680BAC23E83000000000000000000000000000000000_L_1036/eleve_jspdf.js\']);\r\nrequire(\'deferLoadingScript.js\').add (\'tiny\', [\'E_3_C_48869ACD14ADAD7EAB71642D8D101DB000000000000000000000000000000000_L_1036/eleve_tiny.js\']);\r\nrequire(\'deferLoadingScript.js\').add (\'videojs\', [\'E_3_C_98F26C291D809FA439A5ECD9F801AD9000000000000000000000000000000000_L_1036/eleve_videojs.js\']);\r\nrequire(\'deferLoadingScript.js\').add (\'defer\', [\'E_3_C_E872852329B2496ECD7A52B4E7ABA67000000000000000000000000000000000_L_1036/eleve_defer.js\']);\r\n</script>\r\n <script type="text/javascript">\r\nfunction messageErreur (e) {\r\n$.get("erreur/" + e).fail(function (){}); alert ("Erreur sur le chargement de la page. Veuillez vider le cache de votre navigateur.")}\r\n </script>\r\n </head>\r\n <body id="id_body" role="application" onload="try { Start ({h:\'1935829\',sCrA:true,sCoA:true,poll:true,a:3,e:\'00000000000\',f:\'xzn5Ht00000000\',g:3,MR:\'B99B77A3D72D3A29B4271FC7B7300E2F791EB8948174BE7B8024667E915446D4EEA0C2424B8D1EBF7E2DDFF94691C6E994E839225C627D140A8F1146D1B0B5F18A09BBD3D8F421CA1E3E4796B301EEBCCF80D81A32A15000000000000000000000000000000000D5921E8A078CDC019B1000000000000000000000000000000000\',ER:\'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010001\'}) } catch (e) { messageErreur (e) } " class="EspaceIndex">\r\n <noscript style="position: absolute; top: 100px" class="Texte12 Gras Espace">Java script non activ\xc3\xa9.\r\nVeuillez le r\xc3\xa9activer.</noscript>\r\n  <div id="div" data-role="page" class="NePasImprimer" style="height:100%"></div>\r\n  <a href="https://www.index-education.com/redirect.php?distrib=FR" target="_blank" style="display:none">PRONOTE 2021 - 0.2.10 gestion de vie scolaire, notes, comp\xc3\xa9tences, absences/retards/dispenses, incidents/punitions/sanctions, stages... INDEX \xc3\x89DUCATION</a>\r\n </body>\r\n</html>\r\n'
2022-06-21 13:10:31,656 DEBUG [_Communication.post] decryption change
Bapt5 commented 2 years ago

I don't understand what do you mean with

Error seems to indicate cache issue

The log you send me is when the app crash?

vingerha commented 2 years ago

Ah, no... this is the log after restart, it has a line in it that refers to cache needing refresh... so.. for now we will then wait until it hangs again.

Bapt5 commented 2 years ago

Yes I need the log when the app crash

vingerha commented 2 years ago

started hanging again at 14h...no error...should I move or add logging statement(s)?

Bapt5 commented 2 years ago

If there is no error there is no crash. Send me the log when you have the error KeyError: "MR"

vingerha commented 2 years ago

you do know that is not how it works... :) Not continuing on a log-in is also an issue ... and I agree that without feedback it is quite hard to deal with, it trill is an issue. On the debug sent back above ... might it be that the cache is full due to my process re-re-rerunning hourly? Or is this cache-relate message a normal one when not using a browser? Repeating I am no python expert at all

EDIT: could it be related to running in a container? can I maybe run cache-clearing actions in the script?

bain3 commented 2 years ago

Hi, I'm not sure what you mean by caching issues but pronotepy does not have any cache. If you're keeping the client between runs, then use client.refresh() to reinitialise the connection (it throws away the old Session object, so it basically loses any state known to the pronote server).

I think the issue could be with your network, possibly dropping the connection and then not properly timing out the request. The only part of pronotepy's code that could block for that long are http requests. I'm not aware of any loops or anything that could freeze and not throw an exception.

To make requests timeout (overwriting the default None value globally) after some time, you can add this at the start of your script:

import requests
from requests.adapters import TimeoutSauce

class MyTimeout(TimeoutSauce):
    def __init__(self, *args, **kwargs):
        if kwargs['connect'] is None:
            kwargs['connect'] = 5 # change here for different connection timeout
        if kwargs['read'] is None:
            kwargs['read'] = 5 # change here for different read timeout
        super(MyTimeout, self).__init__(*args, **kwargs)

requests.adapters.TimeoutSauce = MyTimeout

(snippet taken from https://stackoverflow.com/a/22377499/12216348)

I guess we should modify the Session and add it later just for pronotepy.

EDIT: I don't think it's an issue with containerisation

Bapt5 commented 2 years ago

Yes Like @bain3 says : Forgot the cache error, it doesn't concern us. It is a JavaScript error that is not triggered. Just please send me the log when you have the error KeyError: "MR"

vingerha commented 2 years ago

It hung again this morning and I now switched the order in which the script collects data of my kids.... just to find out if it is not coincidentally on the ENT/CAS side (guess not) What is odd is that this started 2 weeks ago, I have been running this script since March without any such issues

vingerha commented 2 years ago

Last update: After having switched the order in which I collect data for my kids, it ran fine from 22/6 11:00 to 23/6 16:00 ... Then started hanging on 23/6 17:00 until today 27th. As it now hangs for the 2nd child collection, previously being the 1st in row, it slowly seems to look like an issue/particularity with that CAS (atrium-sud). There is no error, it just hangs like this (as before)

2022-06-23 15:00:33,067 INFO INIT
2022-06-23 15:00:33,068 DEBUG [ENT https://www.atrium-sud.fr/connexion/login] Logging in with xxxxxxxxxxxxxxxx
Bapt5 commented 2 years ago

I just checked and I think that the problem comes from the ENT atrium which must be overloaded, and which sometimes does not answer

vingerha commented 2 years ago

Seems like a reasonable explanation and since we cannot (I guess) ask the ENT to provide a more stable setup, is there a way that pronote can build in a re-start or so? I am happy to test this out

vingerha commented 2 years ago

And just now, afterr hanging again, I restarted it and got this After a second restart the 'MR' issue no longer showed....


2022-06-28 08:57:46,555 DEBUG Html response1: b'<!DOCTYPE html>\r\n<html lang="fr" xmlns="http://www.w3.org/1999/xhtml">\r\n <head>\r\n <base target="_blank" />\r\n <meta http-equiv="X-UA-Compatible" content="IE=edge" />\r\n <meta http-equiv="expires" content="0"/>\r\n <meta http-equiv="pragma" content="no-cache"/>\r\n <meta http-equiv="cache-control" content="no-cache"/>\r\n <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" />\r\n <title>CENTRE INTERNATIONAL VALBONNE - PRONOTE</title>\r\n <meta name="DC.title" content="CENTRE INTERNATIONAL VALBONNE - PRONOTE" />\r\n <meta name="description" content="PRONOTE gestionsso - CENTRE INTERNATIONAL VALBONNE - VALBONNE (006) - gestion des notes, absences, punitions, cahier de textes pour les \xc3\xa9tablissements scolaires." />\r\n <meta name="DC.description" content="PRONOTE gestionsso - CENTRE INTERNATIONAL VALBONNE - VALBONNE (006) - gestion des notes, absences, punitions, cahier de textes pour les \xc3\xa9tablissements scolaires." />\r\n <meta name="DC.creator" content="CENTRE INTERNATIONAL VALBONNE" />\r\n <meta name="DC.publisher" content="PRONOTE" />\r\n <meta name="DC.coverage" content="VALBONNE (006)" />\r\n <meta name="geo.placename" content="VALBONNE (006)" />\r\n <meta name="robots" content="index" />\r\n <link rel="apple-touch-icon" sizes="180x180" href="./images/apple-touch-icon.png" />\r\n <link rel="icon" type="image/png" href="./images/favicon-32x32.png" sizes="32x32" />\r\n <link rel="icon" type="image/png" href="./images/favicon-16x16.png" sizes="16x16" />\r\n <link rel="manifest" href="./images/manifest.json" />\r\n <link rel="mask-icon" sizes="any" href="./images/favicon.svg" color="#22874b">\r\n <meta name="apple-mobile-web-app-title" content="PRONOTE" />\r\n <meta name="msapplication-config" content="./images/browserconfig.xml" />\r\n <meta name="application-name" content="PRONOTE" />\r\n <meta name="msapplication-TileColor" content="#22874b" />\r\n <meta name="msapplication-TileImage" content="./images/mstile-144x144.png" />\r\n <meta name="theme-color" content="#22874b" />\r\n<link rel="stylesheet" type="text/css" href="E_15_C_88CE8EBFCD816ACBA5BA5230BF6550CDE33FC2A4AF7000000000_L_1036/espace/css/gestionsso.css"/>\r\n<script type="text/javascript" src="E_15_C_00C5BABCACC0872F90DB2545FF2B6243369678836650A844000000000_L_1036/gestionsso_ext.js"></script>\r\n<script type="text/javascript" src="E_15_C_D9F97D890939B22C680BAC23E8365BF13EFB3D011C7647211FCB3B0000000_L_1036/gestionsso_jspdf.js"></script>\r\n<script type="text/javascript" src="E_15_C_36FD56100B1BB22D73895BD530853FC33B8204E6296F88A49D0200000000_L_1036/traductions.js"></script>\r\n<script type="text/javascript" src="E_15_C_D4D2F86434E75BEBB55F86B9F4B71892A398608EAFF448A5B140000000000_L_1036/gestionsso.js"></script>\r\n <script type="text/javascript">\r\nfunction messageErreur (e) {\r\n$.get("erreur/" + e).fail(function (){}); alert ("Erreur sur le chargement de la page. Veuillez vider le cache de votre navigateur.")}\r\n </script>\r\n </head>\r\n <body id="id_body" role="application" onload="try { Start ({h:\'3016488\',z:true,sCrA:true,sCoA:true}) } catch (e) { messageErreur (e) } " class="EspaceIndex">\r\n <noscript style="position: absolute; top: 100px" class="Texte12 Gras Espace">Java script non activ\xc3\xa9.\r\nVeuillez le r\xc3\xa9activer.</noscript>\r\n  <div id="div" data-role="page" class="NePasImprimer" style="height:100%"></div>\r\n  <a href="https://www.index-education.com/redirect.php?distrib=FR" target="_blank" style="display:none">PRONOTE 2021 - 0.2.10 gestion de vie scolaire, notes, comp\xc3\xa9tences, absences/retards/dispenses, incidents/punitions/sanctions, stages... INDEX \xc3\x89DUCATION</a>\r\n </body>\r\n</html>\r\n'
Traceback (most recent call last):
  File "/app/pronote2mqtt.py", line 547, in <module>
    run(myParams)
  File "/app/pronote2mqtt.py", line 159, in run
    myPronote.getData(myParams.pronotePrefixUrl_2,myParams.pronoteUsername_2,myParams.pronotePassword_2,myParams.pronoteCas_2,myParams.pronoteGradesAverages_2,myParams.pronoteParent_2,myParams.pronoteFullName_2)
  File "/app/pronote.py", line 44, in getData
    client = pronotepy.Client('https://'+prefix_url+'.index-education.net/pronote/eleve.html', username, password, _ent)
  File "/usr/local/lib/python3.9/site-packages/pronotepy/clients.py", line 382, in __init__
    super().__init__(pronote_url, username, password, ent, qr_code)
  File "/usr/local/lib/python3.9/site-packages/pronotepy/clients.py", line 81, in __init__
    self.attributes, self.func_options = self.communication.initialise()
  File "/usr/local/lib/python3.9/site-packages/pronotepy/pronoteAPI.py", line 80, in initialise
    "MR": self.attributes["MR"],
KeyError: 'MR'
Bapt5 commented 2 years ago

Seems like a reasonable explanation and since we cannot (I guess) ask the ENT to provide a more stable setup, is there a way that pronote can build in a re-start or so? I am happy to test this out

I think it's you who have to provide in your script that reboot if it didn't work

Bapt5 commented 2 years ago

And just now, afterr hanging again, I restarted it and got this After a second restart the 'MR' issue no longer showed....

2022-06-28 08:57:46,555 DEBUG Html response1: b'<!DOCTYPE html>\r\n<html lang="fr" xmlns="http://www.w3.org/1999/xhtml">\r\n <head>\r\n <base target="_blank" />\r\n <meta http-equiv="X-UA-Compatible" content="IE=edge" />\r\n <meta http-equiv="expires" content="0"/>\r\n <meta http-equiv="pragma" content="no-cache"/>\r\n <meta http-equiv="cache-control" content="no-cache"/>\r\n <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" />\r\n <title>CENTRE INTERNATIONAL VALBONNE - PRONOTE</title>\r\n <meta name="DC.title" content="CENTRE INTERNATIONAL VALBONNE - PRONOTE" />\r\n <meta name="description" content="PRONOTE gestionsso - CENTRE INTERNATIONAL VALBONNE - VALBONNE (006) - gestion des notes, absences, punitions, cahier de textes pour les \xc3\xa9tablissements scolaires." />\r\n <meta name="DC.description" content="PRONOTE gestionsso - CENTRE INTERNATIONAL VALBONNE - VALBONNE (006) - gestion des notes, absences, punitions, cahier de textes pour les \xc3\xa9tablissements scolaires." />\r\n <meta name="DC.creator" content="CENTRE INTERNATIONAL VALBONNE" />\r\n <meta name="DC.publisher" content="PRONOTE" />\r\n <meta name="DC.coverage" content="VALBONNE (006)" />\r\n <meta name="geo.placename" content="VALBONNE (006)" />\r\n <meta name="robots" content="index" />\r\n <link rel="apple-touch-icon" sizes="180x180" href="./images/apple-touch-icon.png" />\r\n <link rel="icon" type="image/png" href="./images/favicon-32x32.png" sizes="32x32" />\r\n <link rel="icon" type="image/png" href="./images/favicon-16x16.png" sizes="16x16" />\r\n <link rel="manifest" href="./images/manifest.json" />\r\n <link rel="mask-icon" sizes="any" href="./images/favicon.svg" color="#22874b">\r\n <meta name="apple-mobile-web-app-title" content="PRONOTE" />\r\n <meta name="msapplication-config" content="./images/browserconfig.xml" />\r\n <meta name="application-name" content="PRONOTE" />\r\n <meta name="msapplication-TileColor" content="#22874b" />\r\n <meta name="msapplication-TileImage" content="./images/mstile-144x144.png" />\r\n <meta name="theme-color" content="#22874b" />\r\n<link rel="stylesheet" type="text/css" href="E_15_C_88CE8EBFCD816ACBA5BA5230BF6550CDE33FC2A4AF7000000000_L_1036/espace/css/gestionsso.css"/>\r\n<script type="text/javascript" src="E_15_C_00C5BABCACC0872F90DB2545FF2B6243369678836650A844000000000_L_1036/gestionsso_ext.js"></script>\r\n<script type="text/javascript" src="E_15_C_D9F97D890939B22C680BAC23E8365BF13EFB3D011C7647211FCB3B0000000_L_1036/gestionsso_jspdf.js"></script>\r\n<script type="text/javascript" src="E_15_C_36FD56100B1BB22D73895BD530853FC33B8204E6296F88A49D0200000000_L_1036/traductions.js"></script>\r\n<script type="text/javascript" src="E_15_C_D4D2F86434E75BEBB55F86B9F4B71892A398608EAFF448A5B140000000000_L_1036/gestionsso.js"></script>\r\n <script type="text/javascript">\r\nfunction messageErreur (e) {\r\n$.get("erreur/" + e).fail(function (){}); alert ("Erreur sur le chargement de la page. Veuillez vider le cache de votre navigateur.")}\r\n </script>\r\n </head>\r\n <body id="id_body" role="application" onload="try { Start ({h:\'3016488\',z:true,sCrA:true,sCoA:true}) } catch (e) { messageErreur (e) } " class="EspaceIndex">\r\n <noscript style="position: absolute; top: 100px" class="Texte12 Gras Espace">Java script non activ\xc3\xa9.\r\nVeuillez le r\xc3\xa9activer.</noscript>\r\n  <div id="div" data-role="page" class="NePasImprimer" style="height:100%"></div>\r\n  <a href="https://www.index-education.com/redirect.php?distrib=FR" target="_blank" style="display:none">PRONOTE 2021 - 0.2.10 gestion de vie scolaire, notes, comp\xc3\xa9tences, absences/retards/dispenses, incidents/punitions/sanctions, stages... INDEX \xc3\x89DUCATION</a>\r\n </body>\r\n</html>\r\n'
Traceback (most recent call last):
  File "/app/pronote2mqtt.py", line 547, in <module>
    run(myParams)
  File "/app/pronote2mqtt.py", line 159, in run
    myPronote.getData(myParams.pronotePrefixUrl_2,myParams.pronoteUsername_2,myParams.pronotePassword_2,myParams.pronoteCas_2,myParams.pronoteGradesAverages_2,myParams.pronoteParent_2,myParams.pronoteFullName_2)
  File "/app/pronote.py", line 44, in getData
    client = pronotepy.Client('https://'+prefix_url+'.index-education.net/pronote/eleve.html', username, password, _ent)
  File "/usr/local/lib/python3.9/site-packages/pronotepy/clients.py", line 382, in __init__
    super().__init__(pronote_url, username, password, ent, qr_code)
  File "/usr/local/lib/python3.9/site-packages/pronotepy/clients.py", line 81, in __init__
    self.attributes, self.func_options = self.communication.initialise()
  File "/usr/local/lib/python3.9/site-packages/pronotepy/pronoteAPI.py", line 80, in initialise
    "MR": self.attributes["MR"],
KeyError: 'MR'

Thanks I will analyse the log this afternoon. And I will try to fix the KeyError.

vingerha commented 2 years ago

Seems like a reasonable explanation and since we cannot (I guess) ask the ENT to provide a more stable setup, is there a way that pronote can build in a re-start or so? I am happy to test this out

I think it's you who have to provide in your script that reboot if it didn't work

Not sure how to do this as it hangs in pronoteAPI.py... any pointers/ideas welcome (note: not a real dev. myself)... donot need solution just direction...then internet will help me further :)

Bapt5 commented 2 years ago

I think that it hangs more specifically in the function atrium_sud. I suggest you use a timeout.

Bapt5 commented 2 years ago

I just fixed the KeyError: "MR" issue

vingerha commented 2 years ago

Will you roll this out in a release soon ? As I am embedding pronotepy in a image that would be easiest...but maybe you want me to test this first which is perfectly fine too, should I use 'master' or ... which file(s) to update?

bain3 commented 2 years ago

I just fixed the KeyError: "MR" issue

Could you make a PR? I'll follow up with making sure pronotepy's requests.Session has a timeout.

Bapt5 commented 2 years ago

Yes I will do that this evening

bain3 commented 2 years ago

Didn't mean to close this, we still need to add the timeouts. But the KeyError issue may be fixed now.

vingerha commented 2 years ago

I have added "master" to my container and will see what happens. With the schoolyear ending there will be much less use so probably also less risk in hanging...but I will let you know. Thanks for now!

vingerha commented 2 years ago

And with the new year, the issue is back on the board, my agora06 was hanging this morning at 7:00 (6:00 run was fine). I assume that the 'timeouts' have not yet been added?

bain3 commented 2 years ago

Nope, not yet. You could try to modify the requests module globally like I suggested. Noone else seems to have this issue... If the problem is in fact because of requests that do not timeout, then I can make it easier to modify / add our own timeout class.

vingerha commented 2 years ago

Agree that a single-person-issue should not get high prio. I added the 'import requests' suggestion now...let's wait and see. Thanks

bain3 commented 1 year ago

Any updates on this? @vingerha

vingerha commented 1 year ago

Sorry for not returning ... I added the suggested part in my script and until now all seems to be fine so from my pov you can close this or use it to add some stuff to the pronotepy package

bain3 commented 1 year ago

Glad to hear!