Skip to content

Commit

Permalink
Merge branch '5.9' into 5.9
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton authored Oct 28, 2024
2 parents e7d8acf + 3e39c88 commit 74e027c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions plugins/DigitalLibrary/src/DigitalFactoryApiClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def getListOfFilesInProject(self, library_project_id: str, on_finished: Callable
url = "{}/projects/{}/files".format(self.CURA_API_ROOT, library_project_id)
self._http.get(url,
scope = self._scope,
callback = self._parseCallback(on_finished, DigitalFactoryFileResponse, failed),
callback = self._parseCallback(on_finished, DigitalFactoryFileResponse, failed, default_values = {'username': ''}),
error_callback = failed,
timeout = self.DEFAULT_REQUEST_TIMEOUT)

Expand All @@ -205,7 +205,8 @@ def _parseCallback(self,
Callable[[List[CloudApiClientModel]], Any]],
model: Type[CloudApiClientModel],
on_error: Optional[Callable] = None,
pagination_manager: Optional[PaginationManager] = None) -> Callable[[QNetworkReply], None]:
pagination_manager: Optional[PaginationManager] = None,
default_values: Dict[str, str] = None) -> Callable[[QNetworkReply], None]:

"""
Creates a callback function so that it includes the parsing of the response into the correct model.
Expand Down Expand Up @@ -234,7 +235,7 @@ def parse(reply: QNetworkReply) -> None:
if status_code >= 300 and on_error is not None:
on_error()
else:
self._parseModels(response, on_finished, model, pagination_manager = pagination_manager)
self._parseModels(response, on_finished, model, pagination_manager = pagination_manager, default_values = default_values)

self._anti_gc_callbacks.append(parse)
return parse
Expand Down Expand Up @@ -262,7 +263,8 @@ def _parseModels(self,
on_finished: Union[Callable[[CloudApiClientModel], Any],
Callable[[List[CloudApiClientModel]], Any]],
model_class: Type[CloudApiClientModel],
pagination_manager: Optional[PaginationManager] = None) -> None:
pagination_manager: Optional[PaginationManager] = None,
default_values: Dict[str, str] = None) -> None:
"""Parses the given models and calls the correct callback depending on the result.
:param response: The response from the server, after being converted to a dict.
Expand All @@ -279,7 +281,10 @@ def _parseModels(self,
if "links" in response and pagination_manager:
pagination_manager.setLinks(response["links"])
if isinstance(data, list):
results = [model_class(**c) for c in data] # type: List[CloudApiClientModel]
results = [] # type: List[CloudApiClientModel]
for model_data in data:
complete_model_data = (default_values | model_data) if default_values is not None else model_data
results.append(model_class(**complete_model_data))
on_finished_list = cast(Callable[[List[CloudApiClientModel]], Any], on_finished)
on_finished_list(results)
else:
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/ultimaker_original.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"machine_start_gcode": { "default_value": "G21 ;metric values\nG90 ;absolute positioning\nM82 ;set extruder to absolute mode\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15.0 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E6 ;extrude 6 mm of feed stock\nG92 E0 ;zero the extruded length again\nG1 Y50 F9000\n;Put printing message on LCD screen\nM117 Printing..." },
"machine_use_extruder_offset_to_offset_coords": { "default_value": true },
"machine_width": { "default_value": 205 },
"material_print_temp_wait": { "value": true },
"speed_slowdown_layers": { "value": 2 }
}
}

0 comments on commit 74e027c

Please sign in to comment.