mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Include log file when exporting project file for support
CURA-12138
This commit is contained in:
parent
8d2bef86d6
commit
f28482ebac
2 changed files with 24 additions and 3 deletions
|
@ -8,9 +8,11 @@ from io import StringIO
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
import zipfile
|
import zipfile
|
||||||
from typing import Dict, Any
|
from typing import Dict, Any
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
|
from UM.PluginRegistry import PluginRegistry
|
||||||
from UM.Preferences import Preferences
|
from UM.Preferences import Preferences
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
from UM.Workspace.WorkspaceWriter import WorkspaceWriter
|
from UM.Workspace.WorkspaceWriter import WorkspaceWriter
|
||||||
|
@ -33,7 +35,7 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
|
||||||
if self._ucp_model != model:
|
if self._ucp_model != model:
|
||||||
self._ucp_model = model
|
self._ucp_model = model
|
||||||
|
|
||||||
def _write(self, stream, nodes, mode=WorkspaceWriter.OutputMode.BinaryMode):
|
def _write(self, stream, nodes, mode, include_log):
|
||||||
application = Application.getInstance()
|
application = Application.getInstance()
|
||||||
machine_manager = application.getMachineManager()
|
machine_manager = application.getMachineManager()
|
||||||
|
|
||||||
|
@ -79,6 +81,11 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
|
||||||
if self._ucp_model is not None:
|
if self._ucp_model is not None:
|
||||||
user_settings_data = self._getUserSettings(self._ucp_model)
|
user_settings_data = self._getUserSettings(self._ucp_model)
|
||||||
ThreeMFWriter._storeMetadataJson(user_settings_data, archive, USER_SETTINGS_PATH)
|
ThreeMFWriter._storeMetadataJson(user_settings_data, archive, USER_SETTINGS_PATH)
|
||||||
|
|
||||||
|
# Write log file
|
||||||
|
if include_log:
|
||||||
|
ThreeMFWorkspaceWriter._writeLogFile(archive)
|
||||||
|
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
self.setInformation(catalog.i18nc("@error:zip", "No permission to write the workspace here."))
|
self.setInformation(catalog.i18nc("@error:zip", "No permission to write the workspace here."))
|
||||||
Logger.error("No permission to write workspace to this stream.")
|
Logger.error("No permission to write workspace to this stream.")
|
||||||
|
@ -125,8 +132,8 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def write(self, stream, nodes, mode=WorkspaceWriter.OutputMode.BinaryMode):
|
def write(self, stream, nodes, mode=WorkspaceWriter.OutputMode.BinaryMode, **kwargs):
|
||||||
success = self._write(stream, nodes, mode=WorkspaceWriter.OutputMode.BinaryMode)
|
success = self._write(stream, nodes, WorkspaceWriter.OutputMode.BinaryMode, kwargs.get("include_log", False))
|
||||||
self._ucp_model = None
|
self._ucp_model = None
|
||||||
return success
|
return success
|
||||||
|
|
||||||
|
@ -191,6 +198,17 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
|
||||||
Logger.error("File became inaccessible while writing to it: {archive_filename}".format(archive_filename = archive.fp.name))
|
Logger.error("File became inaccessible while writing to it: {archive_filename}".format(archive_filename = archive.fp.name))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _writeLogFile(archive):
|
||||||
|
"""Helper function that writes the Cura log file to the archive.
|
||||||
|
|
||||||
|
:param archive: The archive to write to.
|
||||||
|
"""
|
||||||
|
file_logger = PluginRegistry.getInstance().getPluginObject("FileLogger")
|
||||||
|
file_logger.flush()
|
||||||
|
for file_path in file_logger.getFilesPaths():
|
||||||
|
archive.write(file_path, arcname=f"log/{Path(file_path).name}")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _getUserSettings(model: SettingsExportModel) -> Dict[str, Dict[str, Any]]:
|
def _getUserSettings(model: SettingsExportModel) -> Dict[str, Dict[str, Any]]:
|
||||||
user_settings = {}
|
user_settings = {}
|
||||||
|
|
|
@ -564,6 +564,9 @@ Item
|
||||||
"preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml",
|
"preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml",
|
||||||
"limit_mimetypes": ["application/vnd.ms-package.3dmanufacturing-3dmodel+xml"],
|
"limit_mimetypes": ["application/vnd.ms-package.3dmanufacturing-3dmodel+xml"],
|
||||||
"silent_save": true,
|
"silent_save": true,
|
||||||
|
"writer_args": {
|
||||||
|
"include_log": true
|
||||||
|
}
|
||||||
};
|
};
|
||||||
UM.OutputDeviceManager.requestWriteToDevice("local_file", exportName, args)
|
UM.OutputDeviceManager.requestWriteToDevice("local_file", exportName, args)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue