Hardcode plugin id for UsbPrinter and XmlMaterialProfile

Previous solution was more defensive but also introduced dependencies
and extra files for minor benefit

CURA-6255
This commit is contained in:
Nino van Hooff 2019-12-30 12:04:41 +01:00
parent 8ae7459ea7
commit 9aa5c3cd24
3 changed files with 3 additions and 8 deletions

View file

@ -88,9 +88,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
self._firmware_name_requested = False self._firmware_name_requested = False
self._firmware_updater = AvrFirmwareUpdater(self) self._firmware_updater = AvrFirmwareUpdater(self)
from .USBPrinterOutputDeviceManager import USBPrinterOutputDeviceManager plugin_path = PluginRegistry.getInstance().getPluginPath("USBPrinting")
plugin_id = USBPrinterOutputDeviceManager.getInstance().getPluginId()
plugin_path = PluginRegistry.getInstance().getPluginPath(plugin_id)
self._monitor_view_qml_path = os.path.join(plugin_path, "MonitorItem.qml") self._monitor_view_qml_path = os.path.join(plugin_path, "MonitorItem.qml")
CuraApplication.getInstance().getOnExitCallbackManager().addCallback(self._checkActivePrintingUponAppExit) CuraApplication.getInstance().getOnExitCallbackManager().addCallback(self._checkActivePrintingUponAppExit)

View file

@ -20,7 +20,6 @@ from UM.ConfigurationErrorMessage import ConfigurationErrorMessage
from cura.CuraApplication import CuraApplication from cura.CuraApplication import CuraApplication
from cura.Machines.ContainerTree import ContainerTree from cura.Machines.ContainerTree import ContainerTree
from cura.Machines.VariantType import VariantType from cura.Machines.VariantType import VariantType
from plugins.XmlMaterialProfile import PluginInfo
try: try:
from .XmlMaterialValidator import XmlMaterialValidator from .XmlMaterialValidator import XmlMaterialValidator
@ -1070,8 +1069,7 @@ class XmlMaterialProfile(InstanceContainer):
# This loads the mapping from a file. # This loads the mapping from a file.
@classmethod @classmethod
def getProductIdMap(cls) -> Dict[str, List[str]]: def getProductIdMap(cls) -> Dict[str, List[str]]:
plugin_id = PluginInfo.getInstance().getPluginId() plugin_path = PluginRegistry.getInstance().getPluginPath("XmlMaterialProfile")
plugin_path = PluginRegistry.getInstance().getPluginPath(plugin_id)
product_to_id_file = os.path.join(plugin_path, "product_to_id.json") product_to_id_file = os.path.join(plugin_path, "product_to_id.json")
with open(product_to_id_file, encoding = "utf-8") as f: with open(product_to_id_file, encoding = "utf-8") as f:
product_to_id_map = json.load(f) product_to_id_map = json.load(f)

View file

@ -1,6 +1,6 @@
# Copyright (c) 2017 Ultimaker B.V. # Copyright (c) 2017 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from plugins.XmlMaterialProfile.PluginInfo import PluginInfo
from . import XmlMaterialProfile from . import XmlMaterialProfile
from . import XmlMaterialUpgrader from . import XmlMaterialUpgrader
@ -46,5 +46,4 @@ def register(app):
return {"version_upgrade": upgrader, return {"version_upgrade": upgrader,
"settings_container": XmlMaterialProfile.XmlMaterialProfile("default_xml_material_profile"), "settings_container": XmlMaterialProfile.XmlMaterialProfile("default_xml_material_profile"),
"plugin_info": PluginInfo()
} }