本文整理汇总了Python中UM.JobQueue.JobQueue.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python JobQueue.getInstance方法的具体用法?Python JobQueue.getInstance怎么用?Python JobQueue.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UM.JobQueue.JobQueue
的用法示例。
在下文中一共展示了JobQueue.getInstance方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from UM.JobQueue import JobQueue [as 别名]
# 或者: from UM.JobQueue.JobQueue import getInstance [as 别名]
def __init__(self):
Resources.addSearchPath(os.path.join(QtApplication.getInstallPrefix(), "share", "cura", "resources"))
if not hasattr(sys, "frozen"):
Resources.addSearchPath(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "resources"))
self._open_file_queue = [] # Files to open when plug-ins are loaded.
super().__init__(name = "cura", version = CuraVersion)
self.setWindowIcon(QIcon(Resources.getPath(Resources.Images, "cura-icon.png")))
self.setRequiredPlugins([
"CuraEngineBackend",
"MeshView",
"LayerView",
"STLReader",
"SelectionTool",
"CameraTool",
"GCodeWriter",
"LocalFileOutputDevice"
])
self._physics = None
self._volume = None
self._platform = None
self._output_devices = {}
self._print_information = None
self._i18n_catalog = None
self._previous_active_tool = None
self._platform_activity = False
self._scene_boundingbox = AxisAlignedBox()
self._job_name = None
self._center_after_select = False
self._camera_animation = None
self._cura_actions = None
self.getMachineManager().activeMachineInstanceChanged.connect(self._onActiveMachineChanged)
self.getMachineManager().addMachineRequested.connect(self._onAddMachineRequested)
self.getController().getScene().sceneChanged.connect(self.updatePlatformActivity)
self.getController().toolOperationStopped.connect(self._onToolOperationStopped)
Resources.addType(self.ResourceTypes.QmlFiles, "qml")
Resources.addType(self.ResourceTypes.Firmware, "firmware")
Preferences.getInstance().addPreference("cura/active_machine", "")
Preferences.getInstance().addPreference("cura/active_mode", "simple")
Preferences.getInstance().addPreference("cura/recent_files", "")
Preferences.getInstance().addPreference("cura/categories_expanded", "")
Preferences.getInstance().addPreference("view/center_on_select", True)
Preferences.getInstance().addPreference("mesh/scale_to_fit", True)
Preferences.getInstance().setDefault("local_file/last_used_type", "text/x-gcode")
JobQueue.getInstance().jobFinished.connect(self._onJobFinished)
self._recent_files = []
files = Preferences.getInstance().getValue("cura/recent_files").split(";")
for f in files:
if not os.path.isfile(f):
continue
self._recent_files.append(QUrl.fromLocalFile(f))
示例2: __init__
# 需要导入模块: from UM.JobQueue import JobQueue [as 别名]
# 或者: from UM.JobQueue.JobQueue import getInstance [as 别名]
def __init__(self):
Resources.addSearchPath(os.path.join(QtApplication.getInstallPrefix(), "share", "nk"))
if not hasattr(sys, "frozen"):
Resources.addSearchPath(os.path.join(os.path.abspath(os.path.dirname(__file__)), ".."))
super().__init__(name="nk", version=NinjaVersion)
self.setWindowIcon(QIcon(Resources.getPath(Resources.Images, "nk-icon.png")))
self.setRequiredPlugins([
"NinjaKittenBackend",
"MeshView",
"STLReader",
"SelectionTool",
"CameraTool",
"TrotecWriter",
"LocalFileOutputDevice"
])
self._volume = None
self._platform = None
self._output_devices = {}
self._i18n_catalog = None
self._previous_active_tool = None
self._platform_activity = False
self._job_name = None
self.getController().getScene().sceneChanged.connect(self.updatePlatformActivity)
Resources.addType(self.ResourceTypes.QmlFiles, "qml")
Preferences.getInstance().addPreference("nk/active_machine", "")
Preferences.getInstance().addPreference("nk/active_mode", "simple")
Preferences.getInstance().addPreference("nk/recent_files", "")
Preferences.getInstance().addPreference("nk/categories_expanded", "")
Preferences.getInstance().addPreference("view/center_on_select", True)
Preferences.getInstance().addPreference("mesh/scale_to_fit", True)
JobQueue.getInstance().jobFinished.connect(self._onJobFinished)
self._recent_files = []
files = Preferences.getInstance().getValue("nk/recent_files").split(";")
for f in files:
if not os.path.isfile(f):
continue
self._recent_files.append(QUrl.fromLocalFile(f))
self._addAllMachines()
示例3: __init__
# 需要导入模块: from UM.JobQueue import JobQueue [as 别名]
# 或者: from UM.JobQueue.JobQueue import getInstance [as 别名]
def __init__(self):
Resources.addResourcePath(os.path.join(QtApplication.getInstallPrefix(), "share", "cura"))
if not hasattr(sys, "frozen"):
Resources.addResourcePath(os.path.join(os.path.abspath(os.path.dirname(__file__)), ".."))
super().__init__(name = "cura", version = "master")
self.setWindowIcon(QIcon(Resources.getPath(Resources.ImagesLocation, "cura-icon.png")))
self.setRequiredPlugins([
"CuraEngineBackend",
"MeshView",
"LayerView",
"STLReader",
"SelectionTool",
"CameraTool",
"GCodeWriter",
"LocalFileOutputDevice"
])
self._physics = None
self._volume = None
self._platform = None
self._output_devices = {}
self._print_information = None
self._i18n_catalog = None
self._previous_active_tool = None
self._platform_activity = False
self.activeMachineChanged.connect(self._onActiveMachineChanged)
self.getController().getScene().sceneChanged.connect(self.updatePlatformActivity)
Preferences.getInstance().addPreference("cura/active_machine", "")
Preferences.getInstance().addPreference("cura/active_mode", "simple")
Preferences.getInstance().addPreference("cura/recent_files", "")
Preferences.getInstance().addPreference("cura/categories_expanded", "")
Preferences.getInstance().addPreference("view/center_on_select", True)
Preferences.getInstance().addPreference("mesh/scale_to_fit", True)
JobQueue.getInstance().jobFinished.connect(self._onJobFinished)
self._recent_files = []
files = Preferences.getInstance().getValue("cura/recent_files").split(";")
for f in files:
if not os.path.isfile(f):
continue
self._recent_files.append(QUrl.fromLocalFile(f))
示例4: test_create
# 需要导入模块: from UM.JobQueue import JobQueue [as 别名]
# 或者: from UM.JobQueue.JobQueue import getInstance [as 别名]
def test_create(self):
JobQueue._instance = None
jq = JobQueue()
assert len(jq._threads) > 0
assert jq == JobQueue.getInstance()
JobQueue._instance = None
jq = JobQueue(4)
assert len(jq._threads) == 4
示例5: __init__
# 需要导入模块: from UM.JobQueue import JobQueue [as 别名]
# 或者: from UM.JobQueue.JobQueue import getInstance [as 别名]
def __init__(self, parent = None):
super().__init__(parent)
jobQueue = JobQueue.getInstance()
jobQueue.jobStarted.connect(self._onJobStarted)
jobQueue.jobFinished.connect(self._onJobFinished)
self._watched_job_indices = {}
self.addRoleName(self.IdRole, "id")
self.addRoleName(self.DescriptionRole, "description")
self.addRoleName(self.ProgressRole, "progress")
示例6: test_create
# 需要导入模块: from UM.JobQueue import JobQueue [as 别名]
# 或者: from UM.JobQueue.JobQueue import getInstance [as 别名]
def test_create(self):
JobQueue._instance = None
jq = JobQueue()
self.assertGreater(len(jq._threads), 0)
self.assertEqual(jq, JobQueue.getInstance())
JobQueue._instance = None
jq = JobQueue(4)
self.assertEqual(len(jq._threads), 4)
示例7: test_add
# 需要导入模块: from UM.JobQueue import JobQueue [as 别名]
# 或者: from UM.JobQueue.JobQueue import getInstance [as 别名]
def test_add(self):
jq = JobQueue.getInstance()
job = TestJob()
job.start()
self.assertIn(job, jq._jobs)
time.sleep(0.1)
self.assertEqual(job.isFinished(), True)
self.assertEqual(job.getResult(), "TestJob")
job1 = TestJob()
job2 = TestJob()
job1.start()
job2.start()
time.sleep(0.1)
self.assertEqual(job1.isFinished(), True)
self.assertEqual(job1.getResult(), "TestJob")
self.assertEqual(job2.isFinished(), True)
self.assertEqual(job2.getResult(), "TestJob")
job = LongTestJob()
job.start()
time.sleep(1)
self.assertEqual(job.isFinished(), False)
self.assertEqual(job.getResult(), None)
time.sleep(1)
self.assertEqual(job.isFinished(), True)
self.assertEqual(job.getResult(), "LongTestJob")
jobs = []
for i in range(10):
job = TestJob()
job.start()
jobs.append(job)
time.sleep(0.5)
for job in jobs:
self.assertEqual(job.isFinished(), True)
self.assertEqual(job.getResult(), "TestJob")
示例8: cancel
# 需要导入模块: from UM.JobQueue import JobQueue [as 别名]
# 或者: from UM.JobQueue.JobQueue import getInstance [as 别名]
def cancel(self):
JobQueue.getInstance().remove(self)
示例9: start
# 需要导入模块: from UM.JobQueue import JobQueue [as 别名]
# 或者: from UM.JobQueue.JobQueue import getInstance [as 别名]
def start(self):
JobQueue.getInstance().add(self)
示例10: __init__
# 需要导入模块: from UM.JobQueue import JobQueue [as 别名]
# 或者: from UM.JobQueue.JobQueue import getInstance [as 别名]
def __init__(self):
Resources.addSearchPath(os.path.join(QtApplication.getInstallPrefix(), "share", "cura", "resources"))
if not hasattr(sys, "frozen"):
Resources.addSearchPath(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "resources"))
self._open_file_queue = [] # Files to open when plug-ins are loaded.
# Need to do this before ContainerRegistry tries to load the machines
SettingDefinition.addSupportedProperty("settable_per_mesh", DefinitionPropertyType.Any, default = True, read_only = True)
SettingDefinition.addSupportedProperty("settable_per_extruder", DefinitionPropertyType.Any, default = True, read_only = True)
# this setting can be changed for each group in one-at-a-time mode
SettingDefinition.addSupportedProperty("settable_per_meshgroup", DefinitionPropertyType.Any, default = True, read_only = True)
SettingDefinition.addSupportedProperty("settable_globally", DefinitionPropertyType.Any, default = True, read_only = True)
# From which stack the setting would inherit if not defined per object (handled in the engine)
# AND for settings which are not settable_per_mesh:
# which extruder is the only extruder this setting is obtained from
SettingDefinition.addSupportedProperty("limit_to_extruder", DefinitionPropertyType.Function, default = "-1")
# For settings which are not settable_per_mesh and not settable_per_extruder:
# A function which determines the glabel/meshgroup value by looking at the values of the setting in all (used) extruders
SettingDefinition.addSupportedProperty("resolve", DefinitionPropertyType.Function, default = None, depends_on = "value")
SettingDefinition.addSettingType("extruder", None, str, Validator)
SettingFunction.registerOperator("extruderValues", cura.Settings.ExtruderManager.getExtruderValues)
SettingFunction.registerOperator("extruderValue", cura.Settings.ExtruderManager.getExtruderValue)
SettingFunction.registerOperator("resolveOrValue", cura.Settings.ExtruderManager.getResolveOrValue)
## Add the 4 types of profiles to storage.
Resources.addStorageType(self.ResourceTypes.QualityInstanceContainer, "quality")
Resources.addStorageType(self.ResourceTypes.VariantInstanceContainer, "variants")
Resources.addStorageType(self.ResourceTypes.MaterialInstanceContainer, "materials")
Resources.addStorageType(self.ResourceTypes.UserInstanceContainer, "user")
Resources.addStorageType(self.ResourceTypes.ExtruderStack, "extruders")
Resources.addStorageType(self.ResourceTypes.MachineStack, "machine_instances")
ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.QualityInstanceContainer)
ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.VariantInstanceContainer)
ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.MaterialInstanceContainer)
ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.UserInstanceContainer)
ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.ExtruderStack)
ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.MachineStack)
## Initialise the version upgrade manager with Cura's storage paths.
import UM.VersionUpgradeManager #Needs to be here to prevent circular dependencies.
UM.VersionUpgradeManager.VersionUpgradeManager.getInstance().setCurrentVersions(
{
("quality", UM.Settings.InstanceContainer.Version): (self.ResourceTypes.QualityInstanceContainer, "application/x-uranium-instancecontainer"),
("machine_stack", UM.Settings.ContainerStack.Version): (self.ResourceTypes.MachineStack, "application/x-uranium-containerstack"),
("preferences", UM.Preferences.Version): (Resources.Preferences, "application/x-uranium-preferences"),
("user", UM.Settings.InstanceContainer.Version): (self.ResourceTypes.UserInstanceContainer, "application/x-uranium-instancecontainer")
}
)
self._machine_action_manager = MachineActionManager.MachineActionManager()
self._machine_manager = None # This is initialized on demand.
self._setting_inheritance_manager = None
self._additional_components = {} # Components to add to certain areas in the interface
super().__init__(name = "cura", version = CuraVersion, buildtype = CuraBuildType)
self.setWindowIcon(QIcon(Resources.getPath(Resources.Images, "cura-icon.png")))
self.setRequiredPlugins([
"CuraEngineBackend",
"MeshView",
"LayerView",
"STLReader",
"SelectionTool",
"CameraTool",
"GCodeWriter",
"LocalFileOutputDevice"
])
self._physics = None
self._volume = None
self._output_devices = {}
self._print_information = None
self._previous_active_tool = None
self._platform_activity = False
self._scene_bounding_box = AxisAlignedBox.Null
self._job_name = None
self._center_after_select = False
self._camera_animation = None
self._cura_actions = None
self._started = False
self._message_box_callback = None
self._message_box_callback_arguments = []
self._i18n_catalog = i18nCatalog("cura")
self.getController().getScene().sceneChanged.connect(self.updatePlatformActivity)
self.getController().toolOperationStopped.connect(self._onToolOperationStopped)
Resources.addType(self.ResourceTypes.QmlFiles, "qml")
Resources.addType(self.ResourceTypes.Firmware, "firmware")
#.........这里部分代码省略.........
示例11: __init__
# 需要导入模块: from UM.JobQueue import JobQueue [as 别名]
# 或者: from UM.JobQueue.JobQueue import getInstance [as 别名]
def __init__(self):
Resources.addSearchPath(os.path.join(QtApplication.getInstallPrefix(), "share", "cura", "resources"))
if not hasattr(sys, "frozen"):
Resources.addSearchPath(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "resources"))
self._open_file_queue = [] # Files to open when plug-ins are loaded.
# Need to do this before ContainerRegistry tries to load the machines
SettingDefinition.addSupportedProperty("global_only", DefinitionPropertyType.Function, default = False)
SettingDefinition.addSettingType("extruder", int, str, UM.Settings.Validator)
super().__init__(name = "cura", version = CuraVersion, buildtype = CuraBuildType)
self.setWindowIcon(QIcon(Resources.getPath(Resources.Images, "cura-icon.png")))
self.setRequiredPlugins([
"CuraEngineBackend",
"MeshView",
"LayerView",
"STLReader",
"SelectionTool",
"CameraTool",
"GCodeWriter",
"LocalFileOutputDevice"
])
self._physics = None
self._volume = None
self._platform = None
self._output_devices = {}
self._print_information = None
self._i18n_catalog = None
self._previous_active_tool = None
self._platform_activity = False
self._scene_bounding_box = AxisAlignedBox()
self._job_name = None
self._center_after_select = False
self._camera_animation = None
self._cura_actions = None
self._started = False
self.getController().getScene().sceneChanged.connect(self.updatePlatformActivity)
self.getController().toolOperationStopped.connect(self._onToolOperationStopped)
Resources.addType(self.ResourceTypes.QmlFiles, "qml")
Resources.addType(self.ResourceTypes.Firmware, "firmware")
## Add the 4 types of profiles to storage.
Resources.addStorageType(self.ResourceTypes.QualityInstanceContainer, "quality")
Resources.addStorageType(self.ResourceTypes.VariantInstanceContainer, "variants")
Resources.addStorageType(self.ResourceTypes.MaterialInstanceContainer, "materials")
Resources.addStorageType(self.ResourceTypes.UserInstanceContainer, "user")
Resources.addStorageType(self.ResourceTypes.ExtruderStack, "extruders")
Resources.addStorageType(self.ResourceTypes.MachineStack, "machine_instances")
ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.QualityInstanceContainer)
ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.VariantInstanceContainer)
ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.MaterialInstanceContainer)
ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.UserInstanceContainer)
ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.ExtruderStack)
ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.MachineStack)
# Add empty variant, material and quality containers.
# Since they are empty, they should never be serialized and instead just programmatically created.
# We need them to simplify the switching between materials.
empty_container = ContainerRegistry.getInstance().getEmptyInstanceContainer()
empty_variant_container = copy.deepcopy(empty_container)
empty_variant_container._id = "empty_variant"
empty_variant_container.addMetaDataEntry("type", "variant")
ContainerRegistry.getInstance().addContainer(empty_variant_container)
empty_material_container = copy.deepcopy(empty_container)
empty_material_container._id = "empty_material"
empty_material_container.addMetaDataEntry("type", "material")
ContainerRegistry.getInstance().addContainer(empty_material_container)
empty_quality_container = copy.deepcopy(empty_container)
empty_quality_container._id = "empty_quality"
empty_quality_container.addMetaDataEntry("type", "quality")
ContainerRegistry.getInstance().addContainer(empty_quality_container)
ContainerRegistry.getInstance().load()
Preferences.getInstance().addPreference("cura/active_mode", "simple")
Preferences.getInstance().addPreference("cura/recent_files", "")
Preferences.getInstance().addPreference("cura/categories_expanded", "")
Preferences.getInstance().addPreference("cura/jobname_prefix", True)
Preferences.getInstance().addPreference("view/center_on_select", True)
Preferences.getInstance().addPreference("mesh/scale_to_fit", True)
Preferences.getInstance().addPreference("mesh/scale_tiny_meshes", True)
Preferences.getInstance().setDefault("local_file/last_used_type", "text/x-gcode")
Preferences.getInstance().setDefault("general/visible_settings", """
machine_settings
resolution
layer_height
shell
wall_thickness
top_bottom_thickness
infill
infill_sparse_density
material
material_print_temperature
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from UM.JobQueue import JobQueue [as 别名]
# 或者: from UM.JobQueue.JobQueue import getInstance [as 别名]
def __init__(self, **kwargs):
plugin_path = ""
if sys.platform == "win32":
if hasattr(sys, "frozen"):
plugin_path = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), "PyQt5", "plugins")
Logger.log("i", "Adding QT5 plugin path: %s" % (plugin_path))
QCoreApplication.addLibraryPath(plugin_path)
else:
import site
for dir in site.getsitepackages():
QCoreApplication.addLibraryPath(os.path.join(dir, "PyQt5", "plugins"))
elif sys.platform == "darwin":
plugin_path = os.path.join(Application.getInstallPrefix(), "Resources", "plugins")
if plugin_path:
Logger.log("i", "Adding QT5 plugin path: %s" % (plugin_path))
QCoreApplication.addLibraryPath(plugin_path)
os.environ["QSG_RENDER_LOOP"] = "basic"
super().__init__(sys.argv, **kwargs)
self.setAttribute(Qt.AA_UseDesktopOpenGL)
major_version, minor_version, profile = OpenGLContext.detectBestOpenGLVersion()
if major_version is None and minor_version is None and profile is None:
Logger.log("e", "Startup failed because OpenGL version probing has failed: tried to create a 2.0 and 4.1 context. Exiting")
QMessageBox.critical(None, "Failed to probe OpenGL",
"Could not probe OpenGL. This program requires OpenGL 2.0 or higher. Please check your video card drivers.")
sys.exit(1)
else:
Logger.log("d", "Detected most suitable OpenGL context version: %s" % (
OpenGLContext.versionAsText(major_version, minor_version, profile)))
OpenGLContext.setDefaultFormat(major_version, minor_version, profile = profile)
self._plugins_loaded = False # Used to determine when it's safe to use the plug-ins.
self._main_qml = "main.qml"
self._engine = None
self._renderer = None
self._main_window = None
self._theme = None
self._shutting_down = False
self._qml_import_paths = []
self._qml_import_paths.append(os.path.join(os.path.dirname(sys.executable), "qml"))
self._qml_import_paths.append(os.path.join(Application.getInstallPrefix(), "Resources", "qml"))
try:
self._splash = self._createSplashScreen()
except FileNotFoundError:
self._splash = None
else:
self._splash.show()
self.processEvents()
signal.signal(signal.SIGINT, signal.SIG_DFL)
# This is done here as a lot of plugins require a correct gl context. If you want to change the framework,
# these checks need to be done in your <framework>Application.py class __init__().
i18n_catalog = i18nCatalog("uranium")
self.showSplashMessage(i18n_catalog.i18nc("@info:progress", "Loading plugins..."))
self._loadPlugins()
self.parseCommandLine()
Logger.log("i", "Command line arguments: %s", self._parsed_command_line)
self._plugin_registry.checkRequiredPlugins(self.getRequiredPlugins())
self.showSplashMessage(i18n_catalog.i18nc("@info:progress", "Updating configuration..."))
upgraded = UM.VersionUpgradeManager.VersionUpgradeManager.getInstance().upgrade()
if upgraded:
# Preferences might have changed. Load them again.
# Note that the language can't be updated, so that will always revert to English.
preferences = Preferences.getInstance()
try:
preferences.readFromFile(Resources.getPath(Resources.Preferences, self._application_name + ".cfg"))
except FileNotFoundError:
pass
self.showSplashMessage(i18n_catalog.i18nc("@info:progress", "Loading preferences..."))
try:
file = Resources.getPath(Resources.Preferences, self.getApplicationName() + ".cfg")
Preferences.getInstance().readFromFile(file)
except FileNotFoundError:
pass
self.getApplicationName()
Preferences.getInstance().addPreference("%s/recent_files" % self.getApplicationName(), "")
self._recent_files = []
files = Preferences.getInstance().getValue("%s/recent_files" % self.getApplicationName()).split(";")
for f in files:
if not os.path.isfile(f):
continue
self._recent_files.append(QUrl.fromLocalFile(f))
JobQueue.getInstance().jobFinished.connect(self._onJobFinished)
示例13: start
# 需要导入模块: from UM.JobQueue import JobQueue [as 别名]
# 或者: from UM.JobQueue.JobQueue import getInstance [as 别名]
def start(self) -> None:
JobQueue.getInstance().add(self)