Merge branch 'CURA-6255_incorrect_usage_of__file__' of github.com:Ultimaker/Cura

This commit is contained in:
Jaime van Kessel 2020-01-07 14:10:19 +01:00
commit a1f8c3f281
No known key found for this signature in database
GPG Key ID: 3710727397403C91
3 changed files with 20 additions and 2 deletions

View File

@ -88,7 +88,8 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
self._firmware_name_requested = False
self._firmware_updater = AvrFirmwareUpdater(self)
self._monitor_view_qml_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "MonitorItem.qml")
plugin_path = cast(str, PluginRegistry.getInstance().getPluginPath("USBPrinting"))
self._monitor_view_qml_path = os.path.join(plugin_path, "MonitorItem.qml")
CuraApplication.getInstance().getOnExitCallbackManager().addCallback(self._checkActivePrintingUponAppExit)

View File

@ -0,0 +1,15 @@
from UM.PluginObject import PluginObject
class PluginInfo(PluginObject):
__instance = None # type: PluginInfo
def __init__(self, *args, **kwags):
super().__init__(*args, **kwags)
if PluginInfo.__instance is not None:
raise RuntimeError("Try to create singleton '%s' more than once" % self.__class__.__name__)
PluginInfo.__instance = self
@classmethod
def getInstance(cls, *args, **kwargs) -> "PluginInfo":
return cls.__instance

View File

@ -9,6 +9,7 @@ import sys
from typing import Any, Dict, List, Optional, Tuple, cast, Set, Union
import xml.etree.ElementTree as ET
from UM.PluginRegistry import PluginRegistry
from UM.Resources import Resources
from UM.Logger import Logger
import UM.Dictionary
@ -1068,7 +1069,8 @@ class XmlMaterialProfile(InstanceContainer):
# This loads the mapping from a file.
@classmethod
def getProductIdMap(cls) -> Dict[str, List[str]]:
product_to_id_file = os.path.join(os.path.dirname(sys.modules[cls.__module__].__file__), "product_to_id.json")
plugin_path = cast(str, PluginRegistry.getInstance().getPluginPath("XmlMaterialProfile"))
product_to_id_file = os.path.join(plugin_path, "product_to_id.json")
with open(product_to_id_file, encoding = "utf-8") as f:
product_to_id_map = json.load(f)
product_to_id_map = {key: [value] for key, value in product_to_id_map.items()}