mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 14:44:13 -06:00
Fix some formatting, cleanup import
This commit is contained in:
parent
dc17bd8499
commit
0b1ac87354
2 changed files with 19 additions and 26 deletions
|
@ -48,10 +48,10 @@ class SendMaterialJob(Job):
|
||||||
try:
|
try:
|
||||||
remote_materials_by_guid = self._parseReply(reply)
|
remote_materials_by_guid = self._parseReply(reply)
|
||||||
self._sendMissingMaterials(remote_materials_by_guid)
|
self._sendMissingMaterials(remote_materials_by_guid)
|
||||||
except json.JSONDecodeError as e:
|
except json.JSONDecodeError:
|
||||||
Logger.log("e", "Error parsing materials from printer: %s", e)
|
Logger.logException("w", "Error parsing materials from printer")
|
||||||
except KeyError as e:
|
except KeyError:
|
||||||
Logger.log("e", "Error parsing materials from printer: %s", e)
|
Logger.logException("w", "Error parsing materials from printer")
|
||||||
|
|
||||||
## Determine which materials should be updated and send them to the printer.
|
## Determine which materials should be updated and send them to the printer.
|
||||||
#
|
#
|
||||||
|
@ -157,7 +157,6 @@ class SendMaterialJob(Job):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _parseReply(cls, reply: QNetworkReply) -> Dict[str, ClusterMaterial]:
|
def _parseReply(cls, reply: QNetworkReply) -> Dict[str, ClusterMaterial]:
|
||||||
remote_materials_list = json.loads(reply.readAll().data().decode("utf-8"))
|
remote_materials_list = json.loads(reply.readAll().data().decode("utf-8"))
|
||||||
print("remote_materials_list", remote_materials_list)
|
|
||||||
return {material["guid"]: ClusterMaterial(**material) for material in remote_materials_list}
|
return {material["guid"]: ClusterMaterial(**material) for material in remote_materials_list}
|
||||||
|
|
||||||
## Retrieves a list of local materials
|
## Retrieves a list of local materials
|
||||||
|
|
|
@ -1,19 +1,13 @@
|
||||||
# Copyright (c) 2018 Ultimaker B.V.
|
# Copyright (c) 2018 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
import io
|
|
||||||
import json
|
|
||||||
from typing import Any, List
|
from typing import Any, List
|
||||||
from unittest import TestCase, mock
|
from unittest import TestCase
|
||||||
from unittest.mock import patch, call
|
from unittest.mock import patch, call
|
||||||
|
|
||||||
from PyQt5.QtCore import QByteArray
|
from PyQt5.QtCore import QByteArray
|
||||||
|
|
||||||
from UM.Logger import Logger
|
from UM.Settings.ContainerRegistry import ContainerInterface, ContainerRegistryInterface, DefinitionContainerInterface
|
||||||
from UM.MimeTypeDatabase import MimeType
|
|
||||||
from UM.Settings.ContainerRegistry import ContainerInterface, ContainerRegistryInterface, \
|
|
||||||
DefinitionContainerInterface, ContainerRegistry
|
|
||||||
from plugins.UM3NetworkPrinting.src.ClusterUM3OutputDevice import ClusterUM3OutputDevice
|
from plugins.UM3NetworkPrinting.src.ClusterUM3OutputDevice import ClusterUM3OutputDevice
|
||||||
from plugins.UM3NetworkPrinting.src.Models import ClusterMaterial
|
|
||||||
from plugins.UM3NetworkPrinting.src.SendMaterialJob import SendMaterialJob
|
from plugins.UM3NetworkPrinting.src.SendMaterialJob import SendMaterialJob
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +39,7 @@ class ContainerRegistryMock(ContainerRegistryInterface):
|
||||||
return self.containersMetaData
|
return self.containersMetaData
|
||||||
|
|
||||||
|
|
||||||
class FakeDevice(ClusterUM3OutputDevice):
|
class MockOutputDevice(ClusterUM3OutputDevice):
|
||||||
def _createFormPart(self, content_header, data, content_type=None):
|
def _createFormPart(self, content_header, data, content_type=None):
|
||||||
return "xxx"
|
return "xxx"
|
||||||
|
|
||||||
|
@ -53,20 +47,20 @@ class FakeDevice(ClusterUM3OutputDevice):
|
||||||
class TestSendMaterialJob(TestCase):
|
class TestSendMaterialJob(TestCase):
|
||||||
|
|
||||||
_LOCAL_MATERIAL_WHITE = {'type': 'material', 'status': 'unknown', 'id': 'generic_pla_white',
|
_LOCAL_MATERIAL_WHITE = {'type': 'material', 'status': 'unknown', 'id': 'generic_pla_white',
|
||||||
'base_file': 'generic_pla_white', 'setting_version': 5, 'name': 'White PLA',
|
'base_file': 'generic_pla_white', 'setting_version': 5, 'name': 'White PLA',
|
||||||
'brand': 'Generic', 'material': 'PLA', 'color_name': 'White',
|
'brand': 'Generic', 'material': 'PLA', 'color_name': 'White',
|
||||||
'GUID': 'badb0ee7-87c8-4f3f-9398-938587b67dce', 'version': '1', 'color_code': '#ffffff',
|
'GUID': 'badb0ee7-87c8-4f3f-9398-938587b67dce', 'version': '1', 'color_code': '#ffffff',
|
||||||
'description': 'Test PLA White', 'adhesion_info': 'Use glue.', 'approximate_diameter': '3',
|
'description': 'Test PLA White', 'adhesion_info': 'Use glue.', 'approximate_diameter': '3',
|
||||||
'properties': {'density': '1.00', 'diameter': '2.85', 'weight': '750'},
|
'properties': {'density': '1.00', 'diameter': '2.85', 'weight': '750'},
|
||||||
'definition': 'fdmprinter', 'compatible': True}
|
'definition': 'fdmprinter', 'compatible': True}
|
||||||
|
|
||||||
_LOCAL_MATERIAL_BLACK = {'type': 'material', 'status': 'unknown', 'id': 'generic_pla_black',
|
_LOCAL_MATERIAL_BLACK = {'type': 'material', 'status': 'unknown', 'id': 'generic_pla_black',
|
||||||
'base_file': 'generic_pla_black', 'setting_version': 5, 'name': 'Yellow CPE',
|
'base_file': 'generic_pla_black', 'setting_version': 5, 'name': 'Yellow CPE',
|
||||||
'brand': 'Ultimaker', 'material': 'CPE', 'color_name': 'Black',
|
'brand': 'Ultimaker', 'material': 'CPE', 'color_name': 'Black',
|
||||||
'GUID': '5fbb362a-41f9-4818-bb43-15ea6df34aa4', 'version': '1', 'color_code': '#000000',
|
'GUID': '5fbb362a-41f9-4818-bb43-15ea6df34aa4', 'version': '1', 'color_code': '#000000',
|
||||||
'description': 'Test PLA Black', 'adhesion_info': 'Use glue.', 'approximate_diameter': '3',
|
'description': 'Test PLA Black', 'adhesion_info': 'Use glue.', 'approximate_diameter': '3',
|
||||||
'properties': {'density': '1.01', 'diameter': '2.85', 'weight': '750'},
|
'properties': {'density': '1.01', 'diameter': '2.85', 'weight': '750'},
|
||||||
'definition': 'fdmprinter', 'compatible': True}
|
'definition': 'fdmprinter', 'compatible': True}
|
||||||
|
|
||||||
_REMOTE_MATERIAL_WHITE = {
|
_REMOTE_MATERIAL_WHITE = {
|
||||||
"guid": "badb0ee7-87c8-4f3f-9398-938587b67dce",
|
"guid": "badb0ee7-87c8-4f3f-9398-938587b67dce",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue