Add multi-user AGY authentication, OAuth login and profile isolation
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import asyncio
|
||||
@@ -122,8 +123,10 @@ def parse_agy_usage_output(usage_raw: str, credits_raw: str) -> Dict[str, Any]:
|
||||
|
||||
return data
|
||||
|
||||
async def fetch_and_render_usage_report(is_fa: bool = True) -> str:
|
||||
async def fetch_and_render_usage_report(is_fa: bool = True, user_id: Optional[int] = None) -> str:
|
||||
"""Executes agy /usage and /credits and formats with visual progress bars."""
|
||||
from auth_manager import auth_manager
|
||||
env = auth_manager.get_user_env(user_id) if user_id else os.environ.copy()
|
||||
usage_raw = ""
|
||||
credits_raw = ""
|
||||
try:
|
||||
@@ -131,6 +134,7 @@ async def fetch_and_render_usage_report(is_fa: bool = True) -> str:
|
||||
"agy", "--print", "/usage",
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
env=env,
|
||||
)
|
||||
out1, _ = await proc1.communicate()
|
||||
usage_raw = out1.decode("utf-8", errors="replace").strip()
|
||||
@@ -139,6 +143,7 @@ async def fetch_and_render_usage_report(is_fa: bool = True) -> str:
|
||||
"agy", "--print", "/credits",
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
env=env,
|
||||
)
|
||||
out2, _ = await proc2.communicate()
|
||||
credits_raw = out2.decode("utf-8", errors="replace").strip()
|
||||
|
||||
Reference in New Issue
Block a user