From 6c81c9a73581d1902d1557f78078ab7b136bfa40 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Thu, 6 Oct 2016 15:07:25 +0100 Subject: [PATCH 1/4] Add an example AppData file so that Cura is visible in Linux software centers Fixes: https://github.com/Ultimaker/Cura/issues/530 --- CMakeLists.txt | 2 ++ cura.appdata.xml | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 cura.appdata.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 265e471dd2..99c18b302c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,8 @@ if(NOT APPLE AND NOT WIN32) DESTINATION lib/python${PYTHON_VERSION_MAJOR}/dist-packages/cura) install(FILES ${CMAKE_BINARY_DIR}/cura.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) + install(FILES ${CMAKE_BINARY_DIR}/cura.appdata.xml + DESTINATION ${CMAKE_INSTALL_DATADIR}/appdata) install(FILES cura.sharedmimeinfo DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages/ RENAME cura.xml ) diff --git a/cura.appdata.xml b/cura.appdata.xml new file mode 100644 index 0000000000..5c67814fae --- /dev/null +++ b/cura.appdata.xml @@ -0,0 +1,31 @@ + + + + cura.desktop + CC0-1.0 + AGPL-3.0 and CC-BY-SA-4.0 + Cura + The world's most advanced 3d printer software + +

+ Cura creates a seamless integration between hardware, software and + materials for the best 3D printing experience around. + Cura supports the 3MF, OBJ and STL file formats and is available on + Windows, Mac and Linux. +

+
    +
  • Novices can start printing right away
  • +
  • Experts are able to customize 200 settings to achieve the best results
  • +
  • Optimized profiles for Ultimaker materials
  • +
  • Supported by a global network of Ultimaker certified service partners
  • +
  • Print multiple objects at once with different settings for each object
  • +
  • Cura supports STL, 3MF and OBJ file formats
  • +
  • Open source and completely free
  • +
+
+ + http://software.ultimaker.com/Cura.png + + https://ultimaker.com/en/products/cura-software + Cura +
From 8b0d6e974a68d14e4e1e82343a7ed1f0eef5ac89 Mon Sep 17 00:00:00 2001 From: Jack Ha Date: Sun, 9 Oct 2016 11:54:34 +0200 Subject: [PATCH 2/4] Added lock file writing and checking. CURA-2449 --- cura/CuraApplication.py | 97 +++++++++++++++++++++++++++++------------ 1 file changed, 69 insertions(+), 28 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 150952c4ff..feb7af7c84 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -49,11 +49,44 @@ from PyQt5.QtGui import QColor, QIcon from PyQt5.QtWidgets import QMessageBox from PyQt5.QtQml import qmlRegisterUncreatableType, qmlRegisterSingletonType, qmlRegisterType +from contextlib import contextmanager + import sys import os.path import numpy import copy import urllib +import os +import time + +CONFIG_LOCK_FILENAME = "cura.lock" + +## Contextmanager to create a lock file and remove it afterwards. +@contextmanager +def lockFile(filename): + try: + with open(filename, 'w') as lock_file: + lock_file.write("Lock file - Cura is currently writing") + except: + Logger.log("e", "Could not create lock file [%s]" % filename) + yield + try: + if os.path.exists(filename): + os.remove(filename) + except: + Logger.log("e", "Could not delete lock file [%s]" % filename) + + +## Wait for a lock file to disappear +# the maximum allowable age is settable; if the file is too old, it will be ignored too +def waitFileDisappear(filename, max_age_seconds=10, msg=""): + now = time.time() + while os.path.exists(filename) and now < os.path.getmtime(filename) + max_age_seconds and now > os.path.getmtime(filename): + if msg: + Logger.log("d", msg) + time.sleep(1) + now = time.time() + numpy.seterr(all="ignore") @@ -201,6 +234,11 @@ class CuraApplication(QtApplication): empty_quality_changes_container.addMetaDataEntry("type", "quality_changes") ContainerRegistry.getInstance().addContainer(empty_quality_changes_container) + # Set the filename to create if cura is writing in the config dir. + self._config_lock_filename = os.path.join(Resources.getConfigStoragePath(), CONFIG_LOCK_FILENAME) + # Lock file check: if (another) Cura is writing in the Config dir, one may not be able to read a + # valid set of files. Not entirely fool-proof, but works when you start Cura shortly after shutting down. + waitFileDisappear(self._config_lock_filename, max_age_seconds=10, msg="Waiting for Cura to finish writing in the config dir...") ContainerRegistry.getInstance().load() Preferences.getInstance().addPreference("cura/active_mode", "simple") @@ -308,38 +346,41 @@ class CuraApplication(QtApplication): if not self._started: # Do not do saving during application start return - for instance in ContainerRegistry.getInstance().findInstanceContainers(): - if not instance.isDirty(): - continue + # When starting Cura, we check for the lockFile which is created and deleted here + with lockFile(self._config_lock_filename): - try: - data = instance.serialize() - except NotImplementedError: - continue - except Exception: - Logger.logException("e", "An exception occurred when serializing container %s", instance.getId()) - continue + for instance in ContainerRegistry.getInstance().findInstanceContainers(): + if not instance.isDirty(): + continue - mime_type = ContainerRegistry.getMimeTypeForContainer(type(instance)) - file_name = urllib.parse.quote_plus(instance.getId()) + "." + mime_type.preferredSuffix - instance_type = instance.getMetaDataEntry("type") - path = None - if instance_type == "material": - path = Resources.getStoragePath(self.ResourceTypes.MaterialInstanceContainer, file_name) - elif instance_type == "quality" or instance_type == "quality_changes": - path = Resources.getStoragePath(self.ResourceTypes.QualityInstanceContainer, file_name) - elif instance_type == "user": - path = Resources.getStoragePath(self.ResourceTypes.UserInstanceContainer, file_name) - elif instance_type == "variant": - path = Resources.getStoragePath(self.ResourceTypes.VariantInstanceContainer, file_name) + try: + data = instance.serialize() + except NotImplementedError: + continue + except Exception: + Logger.logException("e", "An exception occurred when serializing container %s", instance.getId()) + continue - if path: - instance.setPath(path) - with SaveFile(path, "wt", -1, "utf-8") as f: - f.write(data) + mime_type = ContainerRegistry.getMimeTypeForContainer(type(instance)) + file_name = urllib.parse.quote_plus(instance.getId()) + "." + mime_type.preferredSuffix + instance_type = instance.getMetaDataEntry("type") + path = None + if instance_type == "material": + path = Resources.getStoragePath(self.ResourceTypes.MaterialInstanceContainer, file_name) + elif instance_type == "quality" or instance_type == "quality_changes": + path = Resources.getStoragePath(self.ResourceTypes.QualityInstanceContainer, file_name) + elif instance_type == "user": + path = Resources.getStoragePath(self.ResourceTypes.UserInstanceContainer, file_name) + elif instance_type == "variant": + path = Resources.getStoragePath(self.ResourceTypes.VariantInstanceContainer, file_name) - for stack in ContainerRegistry.getInstance().findContainerStacks(): - self.saveStack(stack) + if path: + instance.setPath(path) + with SaveFile(path, "wt", -1, "utf-8") as f: + f.write(data) + + for stack in ContainerRegistry.getInstance().findContainerStacks(): + self.saveStack(stack) def saveStack(self, stack): if not stack.isDirty(): From 83caa334a20471bdd8abf55507083081fe82a67d Mon Sep 17 00:00:00 2001 From: Jack Ha Date: Mon, 10 Oct 2016 09:09:31 +0200 Subject: [PATCH 3/4] Also wait for lock file in saveSettings. CURA-2449 --- cura/CuraApplication.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index feb7af7c84..fa22227a43 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -236,9 +236,7 @@ class CuraApplication(QtApplication): # Set the filename to create if cura is writing in the config dir. self._config_lock_filename = os.path.join(Resources.getConfigStoragePath(), CONFIG_LOCK_FILENAME) - # Lock file check: if (another) Cura is writing in the Config dir, one may not be able to read a - # valid set of files. Not entirely fool-proof, but works when you start Cura shortly after shutting down. - waitFileDisappear(self._config_lock_filename, max_age_seconds=10, msg="Waiting for Cura to finish writing in the config dir...") + self.waitConfigLockFile() ContainerRegistry.getInstance().load() Preferences.getInstance().addPreference("cura/active_mode", "simple") @@ -319,6 +317,12 @@ class CuraApplication(QtApplication): self._recent_files.append(QUrl.fromLocalFile(f)) + ## Lock file check: if (another) Cura is writing in the Config dir. + # one may not be able to read a valid set of files while writing. Not entirely fool-proof, + # but works when you start Cura shortly after shutting down. + def waitConfigLockFile(self): + waitFileDisappear(self._config_lock_filename, max_age_seconds=10, msg="Waiting for Cura to finish writing in the config dir...") + def _onEngineCreated(self): self._engine.addImageProvider("camera", CameraImageProvider.CameraImageProvider()) @@ -346,6 +350,8 @@ class CuraApplication(QtApplication): if not self._started: # Do not do saving during application start return + self.waitConfigLockFile() + # When starting Cura, we check for the lockFile which is created and deleted here with lockFile(self._config_lock_filename): From cece4b0f41bc9551fe8d688edbc4916cea5c94e0 Mon Sep 17 00:00:00 2001 From: Tim Kuipers Date: Mon, 10 Oct 2016 11:02:43 +0200 Subject: [PATCH 4/4] fix: nylon has standby temp 175 (CURA-2567) --- resources/materials/ultimaker_nylon_black.xml.fdm_material | 2 +- .../materials/ultimaker_nylon_transparent.xml.fdm_material | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/materials/ultimaker_nylon_black.xml.fdm_material b/resources/materials/ultimaker_nylon_black.xml.fdm_material index 2d013ab408..4eed0b025c 100644 --- a/resources/materials/ultimaker_nylon_black.xml.fdm_material +++ b/resources/materials/ultimaker_nylon_black.xml.fdm_material @@ -20,6 +20,6 @@ Generic Nylon profile. Serves as an example file, data in this file is not corre 250 60 - 100 + 175 diff --git a/resources/materials/ultimaker_nylon_transparent.xml.fdm_material b/resources/materials/ultimaker_nylon_transparent.xml.fdm_material index 639f5188d4..7d80a0568c 100644 --- a/resources/materials/ultimaker_nylon_transparent.xml.fdm_material +++ b/resources/materials/ultimaker_nylon_transparent.xml.fdm_material @@ -20,6 +20,6 @@ Generic Nylon profile. Serves as an example file, data in this file is not corre 250 60 - 100 + 175