fix: backend bash wrapper executing python3 directly and GroupCard component
This commit is contained in:
+13
-20
@@ -1,21 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Backend per il plasmoide KDE Plasma 6: Antigravity Usage Dashboard.
|
||||
#!/usr/bin/env bash
|
||||
# Backend per il plasmoide KDE Plasma 6: Antigravity Usage Dashboard.
|
||||
# Esegue il client Python incorporato per recuperare le quote da Google CloudCode PA.
|
||||
|
||||
Interroga il gateway Google CloudCode PA (https://daily-cloudcode-pa.googleapis.com)
|
||||
leggendo il token OAuth da ~/.gemini/antigravity-cli/antigravity-oauth-token
|
||||
ed eseguendo il refresh automatico se scaduto o non valido.
|
||||
Restituisce lo stato delle quote per le 3 famiglie di modelli:
|
||||
- Gemini (Gemini 3.x Flash / Pro)
|
||||
- Claude (Claude Sonnet 4.6 / Opus 4.6)
|
||||
- GPT-OSS (GPT-OSS 120B)
|
||||
"""
|
||||
|
||||
import json
|
||||
exec /usr/bin/python3 - "$@" << 'EOF'
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
from datetime import datetime, timezone
|
||||
|
||||
TOKEN_FILE = os.path.expanduser("~/.gemini/antigravity-cli/antigravity-oauth-token")
|
||||
@@ -27,7 +20,6 @@ UA = "antigravity/cli/1.1.17"
|
||||
API_CLIENT = "google-cloud-sdk vscode_cloudshelleditor/0.1"
|
||||
METADATA = json.dumps({"ideType": "ANTIGRAVITY", "platform": "LINUX", "pluginType": "GEMINI"})
|
||||
|
||||
|
||||
def get_token_data():
|
||||
if not os.path.exists(TOKEN_FILE):
|
||||
return None
|
||||
@@ -37,7 +29,6 @@ def get_token_data():
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def save_token_data(data):
|
||||
try:
|
||||
tmp = TOKEN_FILE + ".tmp"
|
||||
@@ -47,7 +38,6 @@ def save_token_data(data):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def refresh_token(refresh_tok):
|
||||
req_body = json.dumps({
|
||||
"client_id": CLIENT_ID,
|
||||
@@ -60,7 +50,6 @@ def refresh_token(refresh_tok):
|
||||
res = json.loads(resp.read().decode("utf-8"))
|
||||
return res.get("access_token"), int(res.get("expires_in", 3600))
|
||||
|
||||
|
||||
def call_api(path, token, payload):
|
||||
url = f"{BASE_URL}{path}"
|
||||
headers = {
|
||||
@@ -75,7 +64,6 @@ def call_api(path, token, payload):
|
||||
with urllib.request.urlopen(req, timeout=15) as resp:
|
||||
return json.loads(resp.read().decode("utf-8"))
|
||||
|
||||
|
||||
def parse_iso_epoch(ts):
|
||||
if not ts:
|
||||
return 0
|
||||
@@ -85,7 +73,6 @@ def parse_iso_epoch(ts):
|
||||
except Exception:
|
||||
return 0
|
||||
|
||||
|
||||
def main():
|
||||
data = get_token_data()
|
||||
if not data or "token" not in data:
|
||||
@@ -144,6 +131,7 @@ def main():
|
||||
gem_reset_str = gem_b.get("resetTime", "")
|
||||
gemini_info = {
|
||||
"id": "gemini",
|
||||
"tag": "GEMINI",
|
||||
"name": "Gemini 3.x",
|
||||
"models": "Pro / Flash",
|
||||
"remaining": round(gem_rem, 4),
|
||||
@@ -159,6 +147,7 @@ def main():
|
||||
cld_reset_str = cld_b.get("resetTime", "")
|
||||
claude_info = {
|
||||
"id": "claude",
|
||||
"tag": "CLAUDE",
|
||||
"name": "Claude 4.6",
|
||||
"models": "Sonnet / Opus",
|
||||
"remaining": round(cld_rem, 4),
|
||||
@@ -173,6 +162,7 @@ def main():
|
||||
gpt_reset_str = gpt_b.get("resetTime", "")
|
||||
gpt_info = {
|
||||
"id": "gpt-oss",
|
||||
"tag": "GPT",
|
||||
"name": "GPT-OSS",
|
||||
"models": "120B Medium",
|
||||
"remaining": round(gpt_rem, 4),
|
||||
@@ -184,10 +174,13 @@ def main():
|
||||
out = {
|
||||
"ok": True,
|
||||
"project": project_id,
|
||||
"gemini": gemini_info,
|
||||
"claude": claude_info,
|
||||
"gpt": gpt_info,
|
||||
"groups": [gemini_info, claude_info, gpt_info]
|
||||
}
|
||||
print(json.dumps(out, indent=2))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user