vingerha / pronote2mqtt

Extracts pronote into sqlite-db and makes available in MQTT, adds sensors to HA
MIT License
7 stars 4 forks source link

ModuleNotFoundError: No module named 'hass' #10

Closed monocycler closed 2 years ago

monocycler commented 2 years ago

Hi I got this problem:

$docker run --name pronote2mqtt_test --tty -v /home/barry/pronote2mqtt/app:/app -v /home/barry/pronote2mqtt/data:/data vingerha/pronote2mqtt:latest

Using '/app' as APP directory
Param.py non existing, copying default to app...
pronote.py non existing, copying default to app...
pronote2mqtt.py non existing, copying default to app...
pronote2mqtt.py non existing, copying default to app...
mqtt.py non existing, copying default to app...
Traceback (most recent call last):
  File "/app/pronote2mqtt.py", line 16, in <module>
    import hass
ModuleNotFoundError: No module named 'hass'

barry@mbp2010:~/pronote2mqtt$ docker run vingerha/pronote2mqtt:latest ls app
Using '/app' as APP directory
database.py
hass.py
mqtt.py
param.py
pronote2mqtt.py
pronote.py
requirement.txt
barry@mbp2010:~/pronote2mqtt$ ls -l app
total 96
-rw-r--r-- 1 root root 19965 May  6 15:35 database.py
-rw-r--r-- 1 root root  3033 May  6 15:35 mqtt.py
-rw-r--r-- 1 root root  8939 May  6 15:35 param.py
-rw-r--r-- 1 root root 28623 May  6 15:35 pronote2mqtt.py
-rw-r--r-- 1 root root 25353 May  6 15:35 pronote.py
drwxr-xr-x 2 root root  4096 May  6 15:35 __pycache__

Note lack of hass.py

Is it due to entrypoint.sh lines 32-34 ?

if [ ! -f "$APP/database.py" ]; then
    echo "hass.py non existing, copying default to app..."
    cp /app_temp/hass.py "$APP/hass.py"

database.py should be hass.py?

As a beginner in Docker I am not sure how to "get into" the image to change that entrypoint.sh:

barry@mbp2010:~/pronote2mqtt$ docker run vingerha/pronote2mqtt:latest vi entrypoint.sh
Using '/app' as APP directory
/usr/local/bin/entrypoint.sh: 37: exec: vi: not found

I want to map /app so I can easily set my own pronote and mqtt parameters.

Thanks

vingerha commented 2 years ago

yep.. error in entrypoint.sh... typo...fixed and tested on my machine now (did not do that before...sigh) you need to re-download a fresh image

vingerha commented 2 years ago

some explanations on the other questions. I myself do not (!) use docker compose .. never needed it So, the only thing you need is to know where your volume goes to and if therer is write-access, the docker run script will create the pronote2mqtt folder and app underneath I have a single folder for all my docker container volume mappings, it is on a ssd so it can grow wihtout affecting the OS if that becomes full. So, [path to folder] for me is /home/docker and I have full read/write access to that (/home/docker is virtual as it is actually mapped/mount to my ssd) With that you can then run

docker run --name pronote2mqtt -v [path to your folder]/pronote2mqtt/app:/app -v [path to folder]/docker/pronote2mqtt:/data --tty vingerha/pronote2mqtt:latest

If you get stuck, then please let me know and possibly I have time tomorrow ...then continue using chat on discord (vingerha)

monocycler commented 2 years ago

Thanks! That helped. I was able to connect to the demo account, and publish to my mqtt broker. but when I put in my parent credentials, I get this:

2022-05-06 21:22:58,164 INFO Student 1-----------------------------------------------------
2022-05-06 21:22:58,164 INFO INIT
2022-05-06 21:22:58,165 DEBUG Requesing html: https://00****2t.index-education.net/pronote/eleve.html
2022-05-06 21:22:58,555 DEBUG [_Communication.post] decryption change
2022-05-06 21:22:58,600 DEBUG indentification
...line removed just in case it encodes my username/password...
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pronotepy/pronoteAPI.py", line 265, in aes_decrypt
    return Padding.unpad(cipher.decrypt(data), 16)
  File "/usr/local/lib/python3.9/site-packages/Crypto/Util/Padding.py", line 92, in unpad
    raise ValueError("Padding is incorrect.")
ValueError: Padding is incorrect.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/pronote2mqtt.py", line 548, in <module>
    run(myParams)
  File "/app/pronote2mqtt.py", line 125, in run
    myPronote.getData(myParams.pronotePrefixUrl_1,myParams.pronoteUsername_1,myParams.pronotePassword_1,myParams.pronoteCas_1,myParams.pronoteGradesAverages_1)
  File "/app/pronote.py", line 42, 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 290, in __init__
    super().__init__(pronote_url, username, password, ent)
  File "/usr/local/lib/python3.9/site-packages/pronotepy/clients.py", line 80, in __init__
    self.logged_in = self._login()
  File "/usr/local/lib/python3.9/site-packages/pronotepy/clients.py", line 133, in _login
    dec = e.aes_decrypt(bytes.fromhex(challenge))
  File "/usr/local/lib/python3.9/site-packages/pronotepy/pronoteAPI.py", line 267, in aes_decrypt
    raise CryptoError('Decryption failed while trying to un pad. (probably bad decryption key/iv)')
pronotepy.exceptions.CryptoError: ('Decryption failed while trying to un pad. (probably bad decryption key/iv)', 'exception happened during login -> probably bad username/password')

I am confident my username, password, and URL are good - I tried twice. But this is a parent's account.

vingerha commented 2 years ago

The solution I provided does not take into account parent access, I tried to add this option for my situation and CAS (atrium_sud) and this works. However(!) it only works with a indirect access, if you have been given/using a url which ends with ...parent.html?login=true then for me I could not get this to work, it crashes in the underlying software pronotepy and this I can/will not change. Before I start loading more stuff can you please send url and cas? If you donot want to post this here on the more public site then use discord...there is little risk in sharing url+cas and I will not (!) ask you for name/pwd. It would be good if you have access to the app folder so that I can try to give some instructions to test instead of continuously load to git :)

monocycler commented 2 years ago

Hi vingernha. All is well now (thanks for the parent access)