smodusermc commited on
Commit
e5d5944
·
verified ·
1 Parent(s): afe7edf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -64,24 +64,31 @@ def login_required(f):
64
 
65
  def run_playit_claim_mode():
66
  """
67
- Executes 'playit claim' to generate a claim code, required when the key is missing.
68
  """
69
  try:
70
- # Run 'playit claim' synchronously to get the output
71
  result = subprocess.run(
72
- ['playit', 'claim'],
73
  capture_output=True,
74
  text=True,
75
  timeout=10
76
  )
77
 
78
  if result.returncode == 0:
79
- # The claim code is usually the last word printed by the command
80
- claim_code = result.stdout.strip().split()[-1]
81
- # Call the display function with the claim code
 
 
 
 
 
 
 
 
82
  start_tunneling(claim_code=claim_code)
83
  else:
84
- # --- MODIFIED PART: PRINTING THE ACTUAL ERROR ---
85
  error_details = result.stderr.strip() or "No detailed error output."
86
  print("=" * 50)
87
  print(f"PlayIt Claim FAILED. Details:")
@@ -89,7 +96,6 @@ def run_playit_claim_mode():
89
  print("=" * 50)
90
  server_manager.log(f"PlayIt claim failed: {error_details}", "error")
91
  start_tunneling(error_message="PlayIt 'claim' failed (See logs for details).")
92
- # -----------------------------------------------
93
 
94
  except Exception as e:
95
  server_manager.log(f"Error during PlayIt claim: {e}", "error")
 
64
 
65
  def run_playit_claim_mode():
66
  """
67
+ Executes 'playit agent claim generate' to get a claim code.
68
  """
69
  try:
70
+ # --- FIX: Changed the command from ['playit', 'claim'] to ['playit', 'agent', 'claim', 'generate'] ---
71
  result = subprocess.run(
72
+ ['playit', 'agent', 'claim', 'generate'],
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
+ # If the code is still not reliably found, fall back to the last word if it looks like a code
85
+ if claim_code == 'CODE NOT FOUND':
86
+ # This is a safer guess for a code
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:")
 
96
  print("=" * 50)
97
  server_manager.log(f"PlayIt claim failed: {error_details}", "error")
98
  start_tunneling(error_message="PlayIt 'claim' failed (See logs for details).")
 
99
 
100
  except Exception as e:
101
  server_manager.log(f"Error during PlayIt claim: {e}", "error")