MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / set_var

Method set_var

scratchattach/cloud/_base.py:426–455  ·  view source on GitHub ↗

Sets a cloud variable. Args: variable (str): The name of the cloud variable that should be set (provided without the cloud emoji) value (str): The value the cloud variable should be set to Kwargs: max_retries (int) : Maximum number of ti

(self, variable, value, *, max_retries: int = 2)

Source from the content-addressed store, hash-verified

424 time.sleep(sleep_time)
425
426 def set_var(self, variable, value, *, max_retries: int = 2):
427 """
428 Sets a cloud variable.
429
430 Args:
431 variable (str): The name of the cloud variable that should be set (provided without the cloud emoji)
432 value (str): The value the cloud variable should be set to
433
434 Kwargs:
435 max_retries (int) : Maximum number of times to retry setting the var if setting fails before raising an exception
436 """
437 self._assert_valid_value(value)
438 if not isinstance(variable, str):
439 raise ValueError("cloud var name must be a string")
440 variable = variable.removeprefix("☁ ")
441 if not self.active_connection:
442 self.connect()
443 self._enforce_ratelimit(n=1)
444
445 self.var_sets_since_first += 1
446
447 packet = {
448 "method": "set",
449 "name": "☁ " + variable,
450 "value": value,
451 "user": self.username,
452 "project_id": self.project_id,
453 }
454 self._send_packet(packet, max_retries=max_retries)
455 self.last_var_set = time.time()
456
457 def set_vars(self, var_value_dict, *, intelligent_waits=True, max_retries: int = 2):
458 """

Callers

nothing calls this directly

Calls 4

_assert_valid_valueMethod · 0.95
connectMethod · 0.95
_enforce_ratelimitMethod · 0.95
_send_packetMethod · 0.95

Tested by

no test coverage detected