Merge pull request #6302 from Ultimaker/fix-job-sending

Print job uploading
This commit is contained in:
Chris ter Beke 2019-09-05 14:43:56 +02:00 committed by GitHub
commit e02f0f1480
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 20 deletions

View File

@ -35,8 +35,6 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
def __init__(self, device_id, address: str, properties: Dict[bytes, bytes], connection_type: ConnectionType = ConnectionType.NetworkConnection, parent: QObject = None) -> None:
super().__init__(device_id = device_id, connection_type = connection_type, parent = parent)
self._manager = None # type: Optional[QNetworkAccessManager]
self._last_manager_create_time = None # type: Optional[float]
self._recreate_network_manager_time = 30
self._timeout_time = 10 # After how many seconds of no response should a timeout occur?
self._last_response_time = None # type: Optional[float]
@ -133,12 +131,6 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
self.setConnectionState(ConnectionState.Closed)
# We need to check if the manager needs to be re-created. If we don't, we get some issues when OSX goes to
# sleep.
if time_since_last_response > self._recreate_network_manager_time:
if self._last_manager_create_time is None or time() - self._last_manager_create_time > self._recreate_network_manager_time:
self._createNetworkManager()
assert(self._manager is not None)
elif self._connection_state == ConnectionState.Closed:
# Go out of timeout.
if self._connection_state_before_timeout is not None: # sanity check, but it should never be None here
@ -317,7 +309,6 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
self._manager = QNetworkAccessManager()
self._manager.finished.connect(self._handleOnFinished)
self._last_manager_create_time = time()
self._manager.authenticationRequired.connect(self._onAuthenticationRequired)
if self._properties.get(b"temporary", b"false") != b"true":

View File

@ -171,7 +171,11 @@ class CloudOutputDeviceManager:
machine.setName(device.name)
machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key)
machine.setMetaDataEntry("group_name", device.name)
device.connect()
machine.addConfiguredConnectionType(device.connectionType.value)
CuraApplication.getInstance().getOutputDeviceManager().addOutputDevice(device)
if not device.isConnected():
device.connect()
output_device_manager = CuraApplication.getInstance().getOutputDeviceManager()
if device.key not in output_device_manager.getOutputDeviceIds():
output_device_manager.addOutputDevice(device)

View File

@ -122,9 +122,6 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
self.writeStarted.emit(self)
# Make sure the printer is aware of all new materials as the new print job might contain one.
self.sendMaterialProfiles()
# Export the scene to the correct file type.
job = ExportFileJob(file_handler=file_handler, nodes=nodes, firmware_version=self.firmwareVersion)
job.finished.connect(self._onPrintJobCreated)

View File

@ -236,7 +236,11 @@ class LocalClusterOutputDeviceManager:
machine.setName(device.name)
machine.setMetaDataEntry(self.META_NETWORK_KEY, device.key)
machine.setMetaDataEntry("group_name", device.name)
device.connect()
machine.addConfiguredConnectionType(device.connectionType.value)
CuraApplication.getInstance().getOutputDeviceManager().addOutputDevice(device)
if not device.isConnected():
device.connect()
output_device_manager = CuraApplication.getInstance().getOutputDeviceManager()
if device.key not in output_device_manager.getOutputDeviceIds():
output_device_manager.addOutputDevice(device)

View File

@ -104,7 +104,6 @@ class SendMaterialJob(Job):
parts.append(self.device.createFormPart("name=\"signature_file\"; filename=\"{file_name}\""
.format(file_name = signature_file_name), f.read()))
Logger.log("d", "Syncing material %s with cluster.", material_id)
# FIXME: move form posting to API client
self.device.postFormWithParts(target = "/cluster-api/v1/materials/", parts = parts,
on_finished = self._sendingFinished)
@ -117,7 +116,6 @@ class SendMaterialJob(Job):
body = reply.readAll().data().decode('utf8')
if "not added" in body:
# For some reason the cluster returns a 200 sometimes even when syncing failed.
Logger.log("w", "Error while syncing material: %s", body)
return
# Inform the user that materials have been synced. This message only shows itself when not already visible.
# Because of the guards above it is not shown when syncing failed (which is not always an actual problem).