8Thomas8/arrosage_auto_raspberrypi

Programme principal

Closed this issue · 2 comments

  • Fonction get_last_watered
  • Fonction get_status
  • Fonction init_output
  • Fonction auto_water
  • Fonction pump_on

Toutes les méthodes semblent fonctionner à l'exception de la première.

Lorsqu'il y a déjà eu un arrosage, aucun problème, par contre, quand il n'y a jamais eu d'arrosage, et donc aucun fichier texte créé, il y a une erreur:

Traceback (most recent call last): File "/home/pi/Pythons/arrosage_auto_raspberrypi/app.py", line 19, in get_last_watered f = open("last_watered.txt", "r") FileNotFoundError: [Errno 2] No such file or directory: 'last_watered.txt' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<input>", line 1, in <module> File "/home/pi/Pythons/arrosage_auto_raspberrypi/app.py", line 22, in get_last_watered except len(lw_status_code) != 0: TypeError: object of type 'int' has no len()

Problème réglé grâce à l'exception suivante:
except IOError: