Send to cluster API

Not the normal printer API. That won't work without authentication.

Contributes to issue CURA-5034.
This commit is contained in:
Ghostkeeper 2018-06-11 15:55:49 +02:00
parent 4e46963f58
commit abf77da4c4
No known key found for this signature in database
GPG Key ID: 5252B696FB5E7C7A

View File

@ -18,7 +18,7 @@ if TYPE_CHECKING:
# #
# This way it won't freeze up the interface while sending those materials. # This way it won't freeze up the interface while sending those materials.
class SendMaterialJob(Job): class SendMaterialJob(Job):
def __init__(self, device: "NetworkedPrinterDevice"): def __init__(self, device: "ClusterUM3OutputDevice"):
super().__init__() super().__init__()
self.device = device self.device = device
@ -32,7 +32,6 @@ class SendMaterialJob(Job):
parts = [] parts = []
with open(file_path, "rb") as f: with open(file_path, "rb") as f:
parts.append(self.device._createFormPart("name=\"file\"; filename=\"{file_name}\"".format(file_name = file_name), f.read())) parts.append(self.device._createFormPart("name=\"file\"; filename=\"{file_name}\"".format(file_name = file_name), f.read()))
parts.append(self.device._createFormPart("name=\"filename\"", file_name.encode("utf-8"), "text/plain"))
without_extension, _ = os.path.splitext(file_path) without_extension, _ = os.path.splitext(file_path)
signature_file_path = without_extension + ".sig" signature_file_path = without_extension + ".sig"
@ -41,4 +40,4 @@ class SendMaterialJob(Job):
with open(signature_file_path, "rb") as f: with open(signature_file_path, "rb") as f:
parts.append(self.device._createFormPart("name=\"signature_file\"; filename=\"{file_name}\"".format(file_name = signature_file_name), f.read())) parts.append(self.device._createFormPart("name=\"signature_file\"; filename=\"{file_name}\"".format(file_name = signature_file_name), f.read()))
self.device.postFormWithParts(target = "/materials", parts = parts) self.device.postFormWithParts(target = self.device._api_prefix + "materials/", parts = parts)