MCPcopy Create free account
hub / github.com/CJackHwang/AIstudioProxyAPI / _resolve_auth_file_path

Method _resolve_auth_file_path

launcher/runner.py:270–369  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

268 logger.debug(f"[System] Port {server_target_port} is available")
269
270 def _resolve_auth_file_path(self):
271 if self.args.active_auth_json:
272 candidate_path = os.path.expanduser(self.args.active_auth_json)
273 if os.path.isabs(candidate_path) and os.path.exists(candidate_path):
274 self.effective_active_auth_json_path = candidate_path
275 else:
276 path_rel_to_cwd = os.path.abspath(candidate_path)
277 if os.path.exists(path_rel_to_cwd):
278 self.effective_active_auth_json_path = path_rel_to_cwd
279 else:
280 path_rel_to_script = os.path.join(
281 os.path.dirname(os.path.dirname(__file__)), candidate_path
282 )
283 if os.path.exists(path_rel_to_script):
284 self.effective_active_auth_json_path = path_rel_to_script
285 elif os.path.sep not in candidate_path:
286 for d in [ACTIVE_AUTH_DIR, SAVED_AUTH_DIR]:
287 p = os.path.join(d, candidate_path)
288 if os.path.exists(p):
289 self.effective_active_auth_json_path = p
290 break
291
292 if self.effective_active_auth_json_path:
293 logger.info(f"Using auth file: {self.effective_active_auth_json_path}")
294 else:
295 logger.error(f"Auth file '{self.args.active_auth_json}' not found.")
296 sys.exit(1)
297 else:
298 if self.final_launch_mode != "debug":
299 try:
300 if os.path.exists(ACTIVE_AUTH_DIR):
301 active_json_files = sorted(
302 [
303 f
304 for f in os.listdir(ACTIVE_AUTH_DIR)
305 if f.lower().endswith(".json")
306 ]
307 )
308 if active_json_files:
309 self.effective_active_auth_json_path = os.path.join(
310 ACTIVE_AUTH_DIR, active_json_files[0]
311 )
312 except Exception as e:
313 logger.warning(f"Error scanning active auth dir: {e}")
314
315 if self.final_launch_mode == "debug" and not self.args.auto_save_auth:
316 available_profiles = []
317 for d, label in [
318 (ACTIVE_AUTH_DIR, "active"),
319 (SAVED_AUTH_DIR, "saved"),
320 ]:
321 if os.path.exists(d):
322 try:
323 for f in sorted(os.listdir(d)):
324 if f.lower().endswith(".json"):
325 available_profiles.append(
326 {
327 "name": f"{label}/{f}",

Callers 1

runMethod · 0.95

Calls 4

input_with_timeoutFunction · 0.90
infoMethod · 0.80
errorMethod · 0.80
warningMethod · 0.80

Tested by

no test coverage detected