Make scrape fails on the AI rate limit dash non-critical

This commit is contained in:
2026-06-19 17:12:59 -05:00
parent b34d5b1d97
commit 42d9758ecc
@@ -17,6 +17,10 @@ def waybar(text, klass="good", tooltip=None):
sys.exit(0)
def unknown(tooltip):
waybar('unk <span font-size="7pt">--</span>', "good", tooltip)
def load_auth():
auth_path = Path(os.environ.get("OPENAI_AUTH_FILE", "~/.codex/auth.json")).expanduser()
auth = {}
@@ -69,11 +73,11 @@ def fetch_usage(token, account_id):
return json.load(res)
except urllib.error.HTTPError as exc:
detail = exc.read().decode("utf-8", "replace")[:240]
waybar("AI rate failed", "critical", f"Usage endpoint returned HTTP {exc.code}\n{detail}")
unknown(f"Usage endpoint returned HTTP {exc.code}\n{detail}")
except (OSError, TimeoutError) as exc:
waybar("AI rate failed", "critical", f"Could not reach Codex usage endpoint\n{exc}")
unknown(f"Could not reach Codex usage endpoint\n{exc}")
except json.JSONDecodeError as exc:
waybar("AI rate unreadable", "critical", f"Usage endpoint returned invalid JSON\n{exc}")
unknown(f"Usage endpoint returned invalid JSON\n{exc}")
def window_label(seconds):