Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,34 +61,39 @@ def login_required(f):
|
|
| 61 |
# ====================================================================
|
| 62 |
# === START PLAYIT.GG AGENT FUNCTIONS (CLAIM/SECRET KEY LOGIC) ===
|
| 63 |
# ====================================================================
|
| 64 |
-
|
| 65 |
def run_playit_claim_mode():
|
| 66 |
-
"""
|
| 67 |
-
Executes 'playit agent claim generate' to get a claim code.
|
| 68 |
-
"""
|
| 69 |
try:
|
| 70 |
-
# --- FIX:
|
| 71 |
result = subprocess.run(
|
| 72 |
-
['playit', '
|
| 73 |
capture_output=True,
|
| 74 |
text=True,
|
| 75 |
timeout=10
|
| 76 |
)
|
| 77 |
|
| 78 |
if result.returncode == 0:
|
| 79 |
-
# Assuming the claim code is still the last word (e.g., "claim.playit.gg/CODE")
|
| 80 |
claim_output = result.stdout.strip()
|
| 81 |
-
# Look for the URL, which contains the code
|
| 82 |
-
claim_code = next((line.split('/')[-1] for line in claim_output.splitlines() if 'playit.gg/claim/' in line), 'CODE NOT FOUND')
|
| 83 |
|
| 84 |
-
#
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
claim_code = claim_output.split()[-1]
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
server_manager.log(f"PlayIt Claim code generated: {claim_code}", "success")
|
| 90 |
start_tunneling(claim_code=claim_code)
|
| 91 |
else:
|
|
|
|
| 92 |
error_details = result.stderr.strip() or "No detailed error output."
|
| 93 |
print("=" * 50)
|
| 94 |
print(f"PlayIt Claim FAILED. Details:")
|
|
@@ -99,7 +104,7 @@ def run_playit_claim_mode():
|
|
| 99 |
|
| 100 |
except Exception as e:
|
| 101 |
server_manager.log(f"Error during PlayIt claim: {e}", "error")
|
| 102 |
-
start_tunneling(error_message="PlayIt claim encountered an unexpected error.")
|
| 103 |
|
| 104 |
|
| 105 |
def run_playit_secret_mode():
|
|
|
|
| 61 |
# ====================================================================
|
| 62 |
# === START PLAYIT.GG AGENT FUNCTIONS (CLAIM/SECRET KEY LOGIC) ===
|
| 63 |
# ====================================================================
|
|
|
|
| 64 |
def run_playit_claim_mode():
|
|
|
|
|
|
|
|
|
|
| 65 |
try:
|
| 66 |
+
# --- FIX: Reverting command to the simplest form: ['playit', 'claim'] ---
|
| 67 |
result = subprocess.run(
|
| 68 |
+
['playit', 'claim'],
|
| 69 |
capture_output=True,
|
| 70 |
text=True,
|
| 71 |
timeout=10
|
| 72 |
)
|
| 73 |
|
| 74 |
if result.returncode == 0:
|
|
|
|
| 75 |
claim_output = result.stdout.strip()
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
# Robustly search the output for the actual code (the part after the last /)
|
| 78 |
+
# This handles cases where it prints a full URL like claim.playit.gg/CODE
|
| 79 |
+
claim_code = 'CODE NOT FOUND'
|
| 80 |
+
for line in claim_output.splitlines():
|
| 81 |
+
if 'playit.gg/claim/' in line:
|
| 82 |
+
claim_code = line.split('/')[-1].strip()
|
| 83 |
+
break
|
| 84 |
+
|
| 85 |
+
# Fallback: if no URL was found, try the very last word of the output, which is common.
|
| 86 |
+
if claim_code == 'CODE NOT FOUND' and claim_output:
|
| 87 |
claim_code = claim_output.split()[-1]
|
| 88 |
|
| 89 |
+
if claim_code == 'CODE NOT FOUND':
|
| 90 |
+
raise ValueError("Could not find a valid claim code in playit output.")
|
| 91 |
+
|
| 92 |
+
|
| 93 |
server_manager.log(f"PlayIt Claim code generated: {claim_code}", "success")
|
| 94 |
start_tunneling(claim_code=claim_code)
|
| 95 |
else:
|
| 96 |
+
# Command failed, print detailed error
|
| 97 |
error_details = result.stderr.strip() or "No detailed error output."
|
| 98 |
print("=" * 50)
|
| 99 |
print(f"PlayIt Claim FAILED. Details:")
|
|
|
|
| 104 |
|
| 105 |
except Exception as e:
|
| 106 |
server_manager.log(f"Error during PlayIt claim: {e}", "error")
|
| 107 |
+
start_tunneling(error_message=f"PlayIt claim encountered an unexpected error: {type(e).__name__}.")
|
| 108 |
|
| 109 |
|
| 110 |
def run_playit_secret_mode():
|