mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-02 09:23:35 +08:00
Merge pull request #1609 from Ultimaker/bugfix_CURA-3604
CURA-3604 Fix batched gcode compression for "print over network"
This commit is contained in:
commit
4fe80218bc
@ -795,6 +795,13 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
|||||||
|
|
||||||
byte_array_file_data = b""
|
byte_array_file_data = b""
|
||||||
batched_line = ""
|
batched_line = ""
|
||||||
|
|
||||||
|
def _compress_data_and_notify_qt(file_data, data_to_append):
|
||||||
|
file_data += gzip.compress(data_to_append.encode("utf-8"))
|
||||||
|
QCoreApplication.processEvents() # Ensure that the GUI does not freeze.
|
||||||
|
# Pretend that this is a response, as zipping might take a bit of time.
|
||||||
|
self._last_response_time = time()
|
||||||
|
|
||||||
for line in self._gcode:
|
for line in self._gcode:
|
||||||
if not self._compressing_print:
|
if not self._compressing_print:
|
||||||
self._progress_message.hide()
|
self._progress_message.hide()
|
||||||
@ -807,14 +814,16 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if self._use_gzip:
|
if self._use_gzip:
|
||||||
byte_array_file_data += gzip.compress(batched_line.encode("utf-8"))
|
_compress_data_and_notify_qt(byte_array_file_data, batched_line)
|
||||||
batched_line = ""
|
batched_line = ""
|
||||||
QCoreApplication.processEvents() # Ensure that the GUI does not freeze.
|
|
||||||
# Pretend that this is a response, as zipping might take a bit of time.
|
|
||||||
self._last_response_time = time()
|
|
||||||
else:
|
else:
|
||||||
byte_array_file_data += line.encode("utf-8")
|
byte_array_file_data += line.encode("utf-8")
|
||||||
|
|
||||||
|
# don't miss the last batch if it's there
|
||||||
|
if self._use_gzip:
|
||||||
|
if batched_line:
|
||||||
|
_compress_data_and_notify_qt(byte_array_file_data, batched_line)
|
||||||
|
|
||||||
if self._use_gzip:
|
if self._use_gzip:
|
||||||
file_name = "%s.gcode.gz" % Application.getInstance().getPrintInformation().jobName
|
file_name = "%s.gcode.gz" % Application.getInstance().getPrintInformation().jobName
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user