Skip to content

Commit 49d95a1

Browse files
committed
bugfix: catching auth exception that causes panic when reconnecting
1 parent d673584 commit 49d95a1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

mcidle.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ def try_auth(username, password):
3030
credentials = Auth.read_from_disk()
3131
except FileNotFoundError:
3232
print("Credentials not found..", flush=True)
33-
update_credentials(username, password)
34-
credentials = Auth.read_from_disk()
33+
try:
34+
update_credentials(username, password)
35+
credentials = Auth.read_from_disk()
36+
except Exception as e:
37+
return None
3538

3639
auth = Auth().assign_profile(credentials)
3740

@@ -58,7 +61,11 @@ def init():
5861

5962
while True:
6063
print("Trying to auth..", flush=True)
61-
credentials = try_auth(args.username, args.password) # Make sure we can still auth
64+
try:
65+
credentials = try_auth(args.username, args.password) # Make sure we can still auth
66+
except:
67+
print("Invalid password or blocked from auth server for reconnecting too fast..", flush=True)
68+
6269
print("Finished auth", flush=True)
6370
if credentials:
6471
print("Starting..", flush=True)
@@ -75,7 +82,8 @@ def init():
7582
if not args.username or not args.password:
7683
print("Can't re-auth user because no user or password provided!", flush=True)
7784
return
78-
time.sleep(3)
85+
print("Username or password wrong, waiting 30 seconds before reconnecting..")
86+
time.sleep(30)
7987

8088
if __name__ == '__main__':
8189
init()

0 commit comments

Comments
 (0)