mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Make createFormParts public
Because the postFormWithParts function is public and it needs these parts that can (or should) only be created with this function. Contributes to issue CURA-5034.
This commit is contained in:
parent
2e005a09ac
commit
b2cd0ffc0f
3 changed files with 6 additions and 6 deletions
|
@ -161,7 +161,7 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
|
||||||
request.setHeader(QNetworkRequest.UserAgentHeader, self._user_agent)
|
request.setHeader(QNetworkRequest.UserAgentHeader, self._user_agent)
|
||||||
return request
|
return request
|
||||||
|
|
||||||
def _createFormPart(self, content_header, data, content_type = None) -> QHttpPart:
|
def createFormPart(self, content_header, data, content_type = None) -> QHttpPart:
|
||||||
part = QHttpPart()
|
part = QHttpPart()
|
||||||
|
|
||||||
if not content_header.startswith("form-data;"):
|
if not content_header.startswith("form-data;"):
|
||||||
|
|
|
@ -217,10 +217,10 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
||||||
# If a specific printer was selected, it should be printed with that machine.
|
# If a specific printer was selected, it should be printed with that machine.
|
||||||
if target_printer:
|
if target_printer:
|
||||||
target_printer = self._printer_uuid_to_unique_name_mapping[target_printer]
|
target_printer = self._printer_uuid_to_unique_name_mapping[target_printer]
|
||||||
parts.append(self._createFormPart("name=require_printer_name", bytes(target_printer, "utf-8"), "text/plain"))
|
parts.append(self.createFormPart("name=require_printer_name", bytes(target_printer, "utf-8"), "text/plain"))
|
||||||
|
|
||||||
# Add user name to the print_job
|
# Add user name to the print_job
|
||||||
parts.append(self._createFormPart("name=owner", bytes(self._getUserName(), "utf-8"), "text/plain"))
|
parts.append(self.createFormPart("name=owner", bytes(self._getUserName(), "utf-8"), "text/plain"))
|
||||||
|
|
||||||
file_name = Application.getInstance().getPrintInformation().jobName + "." + preferred_format["extension"]
|
file_name = Application.getInstance().getPrintInformation().jobName + "." + preferred_format["extension"]
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
||||||
if isinstance(stream, io.StringIO):
|
if isinstance(stream, io.StringIO):
|
||||||
output = output.encode("utf-8")
|
output = output.encode("utf-8")
|
||||||
|
|
||||||
parts.append(self._createFormPart("name=\"file\"; filename=\"%s\"" % file_name, output))
|
parts.append(self.createFormPart("name=\"file\"; filename=\"%s\"" % file_name, output))
|
||||||
|
|
||||||
self._latest_reply_handler = self.postFormWithParts("print_jobs/", parts, onFinished=self._onPostPrintJobFinished, onProgress=self._onUploadPrintJobProgress)
|
self._latest_reply_handler = self.postFormWithParts("print_jobs/", parts, onFinished=self._onPostPrintJobFinished, onProgress=self._onUploadPrintJobProgress)
|
||||||
|
|
||||||
|
|
|
@ -83,12 +83,12 @@ 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()))
|
||||||
signature_file_path = file_path + ".sig"
|
signature_file_path = file_path + ".sig"
|
||||||
if os.path.exists(signature_file_path):
|
if os.path.exists(signature_file_path):
|
||||||
_, signature_file_name = os.path.split(signature_file_path)
|
_, signature_file_name = os.path.split(signature_file_path)
|
||||||
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()))
|
||||||
|
|
||||||
Logger.log("d", "Syncing material {material_id} with cluster.".format(material_id = material_id))
|
Logger.log("d", "Syncing material {material_id} with cluster.".format(material_id = material_id))
|
||||||
self.device.postFormWithParts(target = "materials/", parts = parts, onFinished = self.sendingFinished)
|
self.device.postFormWithParts(target = "materials/", parts = parts, onFinished = self.sendingFinished)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue