turtle170 commited on
Commit
208e7fd
·
verified ·
1 Parent(s): ae9810d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -1176,6 +1176,7 @@ kernel = ZeroEngine()
1176
  session_id = "turtle170"
1177
 
1178
  with gr.Blocks(title="ZeroEngine V0.2", css=CUSTOM_CSS) as demo:
 
1179
  # Header with Token Display
1180
  with gr.Row():
1181
  with gr.Column(scale=8):
@@ -1287,15 +1288,16 @@ with gr.Blocks(title="ZeroEngine V0.2", css=CUSTOM_CSS) as demo:
1287
  )
1288
 
1289
  # --- UI LOGIC ---
1290
- def update_stats():
1291
  try:
1292
- m = ResourceMonitor.get_metrics()
1293
- balance = token_manager.get_balance(session_id)
1294
- return f"{m['ram_used_gb']}/{m['ram_total_gb']} GB", f"{m['cpu_usage_pct']}%", f"{balance}"
1295
- except Exception as e:
1296
- logger.error(f"Stats update error: {e}")
1297
- return "Error", "Error", "0.00"
1298
- return "Error", "Error"
 
1299
 
1300
  def on_scan(repo):
1301
  try:
 
1176
  session_id = "turtle170"
1177
 
1178
  with gr.Blocks(title="ZeroEngine V0.2", css=CUSTOM_CSS) as demo:
1179
+ gr.LoginButton()
1180
  # Header with Token Display
1181
  with gr.Row():
1182
  with gr.Column(scale=8):
 
1288
  )
1289
 
1290
  # --- UI LOGIC ---
1291
+ def update_stats(profile: gr.OAuthProfile | None):
1292
  try:
1293
+ m = ResourceMonitor.get_metrics()
1294
+ current_user = profile.username if profile else "Guest"
1295
+ balance = token_manager.get_balance(current_user)
1296
+
1297
+ return f"{m['ram_used_gb']}/{m['ram_total_gb']} GB", f"{m['cpu_usage_pct']}%", f"{balance}"
1298
+ except Exception as e:
1299
+ logger.error(f"Stats update error: {e}")
1300
+ return "Error", "Error", "0.00"
1301
 
1302
  def on_scan(repo):
1303
  try: