Make scrape fails on the AI rate limit dash non-critical
This commit is contained in:
@@ -17,6 +17,10 @@ def waybar(text, klass="good", tooltip=None):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
def unknown(tooltip):
|
||||||
|
waybar('unk <span font-size="7pt">--</span>', "good", tooltip)
|
||||||
|
|
||||||
|
|
||||||
def load_auth():
|
def load_auth():
|
||||||
auth_path = Path(os.environ.get("OPENAI_AUTH_FILE", "~/.codex/auth.json")).expanduser()
|
auth_path = Path(os.environ.get("OPENAI_AUTH_FILE", "~/.codex/auth.json")).expanduser()
|
||||||
auth = {}
|
auth = {}
|
||||||
@@ -69,11 +73,11 @@ def fetch_usage(token, account_id):
|
|||||||
return json.load(res)
|
return json.load(res)
|
||||||
except urllib.error.HTTPError as exc:
|
except urllib.error.HTTPError as exc:
|
||||||
detail = exc.read().decode("utf-8", "replace")[:240]
|
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:
|
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:
|
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):
|
def window_label(seconds):
|
||||||
|
|||||||
Reference in New Issue
Block a user