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

Method logs

scratchattach/cloud/cloud.py:46–67  ·  view source on GitHub ↗

Gets the data from Scratch's clouddata logs. Keyword Arguments: filter_by_var_named (str or None): If you only want to get data for one cloud variable, set this argument to its name. limit (int): Max. amount of returned activity. offset (int): Of

(self, *, filter_by_var_named=None, limit=100, offset=0)

Source from the content-addressed store, hash-verified

44 super().set_vars(var_value_dict, intelligent_waits=intelligent_waits, max_retries=max_retries)
45
46 def logs(self, *, filter_by_var_named=None, limit=100, offset=0) -> list[cloud_activity.CloudActivity]:
47 """
48 Gets the data from Scratch's clouddata logs.
49
50 Keyword Arguments:
51 filter_by_var_named (str or None): If you only want to get data for one cloud variable, set this argument to its name.
52 limit (int): Max. amount of returned activity.
53 offset (int): Offset of the first activity in the returned list.
54 log_url (str): If you want to get the clouddata from a cloud log API different to Scratch's normal cloud log API, set this argument to the URL of the API. Only set this argument if you know what you are doing. If you want to get the clouddata from the normal API, don't put this argument.
55 """
56 try:
57 data = requests.get(
58 f"https://clouddata.scratch.mit.edu/logs?projectid={self.project_id}&limit={limit}&offset={offset}", timeout=10
59 ).json()
60 if filter_by_var_named is not None:
61 filter_by_var_named = filter_by_var_named.removeprefix("☁ ")
62 data = list(filter(lambda k: k["name"] == "☁ " + filter_by_var_named, data))
63 for x in data:
64 x["cloud"] = self
65 return commons.parse_object_list(data, cloud_activity.CloudActivity, self._session, "name")
66 except Exception as e:
67 raise exceptions.FetchError(str(e))
68
69 def get_var(self, var, *, recorder_initial_values: Optional[dict[str, Any]] = None, use_logs=False):
70 var = var.removeprefix("☁ ")

Callers 2

get_varMethod · 0.95
get_all_varsMethod · 0.95

Calls 3

filterFunction · 0.85
jsonMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected