diff options
author | Jesusaves <cpntb1@ymail.com> | 2021-05-17 22:57:28 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2021-05-17 22:57:28 -0300 |
commit | 5c085d5e96372fdc62c75db96b4a5dac635c121d (patch) | |
tree | 326096374152704f12a8b91e94db58eae5772b52 /game/client.rpy | |
parent | f55c8a2a8105d3458806f98cacbd83a6729a6c66 (diff) | |
download | renpy-5c085d5e96372fdc62c75db96b4a5dac635c121d.tar.gz renpy-5c085d5e96372fdc62c75db96b4a5dac635c121d.tar.bz2 renpy-5c085d5e96372fdc62c75db96b4a5dac635c121d.tar.xz renpy-5c085d5e96372fdc62c75db96b4a5dac635c121d.zip |
Improve a bit Vault error handling, no longer allow M+ to launch without credentials
Diffstat (limited to 'game/client.rpy')
-rw-r--r-- | game/client.rpy | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/game/client.rpy b/game/client.rpy index 0644e73..aece878 100644 --- a/game/client.rpy +++ b/game/client.rpy @@ -22,7 +22,7 @@ init 2 python: return f def launch_game(idx): - global progress, responsive + global progress, responsive, statusmsg ######################################################################## ## Setup RPCUpdate(persistent.serverlist[idx]["Name"], persistent.serverlist[idx]["Back"]) @@ -41,17 +41,37 @@ init 2 python: PWD="" try: r=vault.post(VAULT_HOST+"/world_pass", json=auth, timeout=15.0) + ## We got the access credentials if r.status_code == 200: auth2=r.json() PWD=" -U %s -P %s" % (auth2["user"], auth2["pass"]) + ## We were refused by Vault elif r.status_code == 403: stdout("Warning: Connection was refused (Vault logout?)") + statusmsg=_("You're not logged in.") responsive = False return + ## We are rate-limited, try again + elif r.status_code == 429: + statusmsg=_("Rate limited, we'll try again...") + time.sleep(15.0) + r=vault.post(VAULT_HOST+"/world_pass", json=auth, timeout=15.0) + ## Only accept OK this time + if r.status_code != 200: + stdout("Get World Auth - Returned error %d" % r.status_code) + raise Exception("Vault returned error %d" % r.status_code) + auth2=r.json() + PWD=" -U %s -P %s" % (auth2["user"], auth2["pass"]) + ## Internal error, maybe? else: stdout("Get World Auth - Returned error code %d" % r.status_code) + raise Exception("Vault returned error %d" % r.status_code) except: - pass + traceback.print_exc() + statusmsg=_("TMW Vault Error.") + #time.sleep(2.5) + progress = 100 + return ######################################################################## ## Loop |