Added debugging and error handling
This commit is contained in:
parent
a601a6f73a
commit
07e0193db5
|
@ -85,12 +85,18 @@ class Alcasar:
|
|||
|
||||
def update_statut(self):
|
||||
"""Update the connexion statut"""
|
||||
try:
|
||||
data = self.ses.get("http://alcasar-0320002d.smile-education.fr:3990/json/status?callback=chilliJSON.reply")
|
||||
statut = json.loads(
|
||||
data.text[17:-1])
|
||||
except requests.exceptions.RequestException:
|
||||
self.connection_statut = False
|
||||
return False, ""
|
||||
|
||||
self.connection_statut = statut["clientState"]
|
||||
# Update statuts variables with new data
|
||||
self.connection_statut = bool(statut["clientState"])
|
||||
self.logout_url = statut["redir"]["logoutURL"]
|
||||
return self.connection_statut, self.logout_url
|
||||
|
||||
def disconnect(self):
|
||||
"""Disconnect the user from the authentication service"""
|
||||
|
|
4
main.py
4
main.py
|
@ -6,7 +6,7 @@ if __name__ == '__main__':
|
|||
print("Checking if the computer is connected on an Alcasar WI-FI...")
|
||||
if alcasar.detect():
|
||||
print("Alcasar Detected! Connecting...")
|
||||
result = alcasar.connect("BENDJEY", "Q8CSKR")
|
||||
result = alcasar.connect("USERNAME", "PASSWORD")
|
||||
|
||||
# Check result
|
||||
match result:
|
||||
|
@ -23,3 +23,5 @@ if __name__ == '__main__':
|
|||
|
||||
input("disconnect ?")
|
||||
alcasar.disconnect()
|
||||
else:
|
||||
print("Not detected")
|
||||
|
|
Loading…
Reference in a new issue