MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / set_default_instance

Method set_default_instance

unity_cli/client.py:480–516  ·  view source on GitHub ↗

Set the default Unity instance. Args: instance_id: Project path to set as default. Returns: True if successfully set. Raises: InstanceError: If instance not found. ConnectionError: If cannot connect to relay server.

(self, instance_id: str)

Source from the content-addressed store, hash-verified

478 )
479
480 def set_default_instance(self, instance_id: str) -> bool:
481 """Set the default Unity instance.
482
483 Args:
484 instance_id: Project path to set as default.
485
486 Returns:
487 True if successfully set.
488
489 Raises:
490 InstanceError: If instance not found.
491 ConnectionError: If cannot connect to relay server.
492 ProtocolError: For unexpected message types.
493 """
494 message = {
495 "type": "SET_DEFAULT",
496 "id": _generate_request_id(self._client_id),
497 "instance": instance_id,
498 "ts": int(time.time() * 1000),
499 }
500
501 response = self._send_admin_message(message)
502
503 if response.get("type") == "RESPONSE":
504 success: bool = response.get("success", False)
505 return success
506 if response.get("type") == "ERROR":
507 error: dict[str, str] = response.get("error", {})
508 raise InstanceError(
509 error.get("message", "Failed to set default instance"),
510 error.get("code", "UNKNOWN_ERROR"),
511 )
512
513 raise ProtocolError(
514 f"Unexpected response type: {response.get('type')}",
515 "PROTOCOL_ERROR",
516 )
517
518
519# =============================================================================

Callers

nothing calls this directly

Calls 5

_send_admin_messageMethod · 0.95
InstanceErrorClass · 0.90
ProtocolErrorClass · 0.90
_generate_request_idFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected