本文整理汇总了Python中UM.JobQueue.JobQueue类的典型用法代码示例。如果您正苦于以下问题:Python JobQueue类的具体用法?Python JobQueue怎么用?Python JobQueue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JobQueue类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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__
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__
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
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__
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
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
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
def cancel(self):
JobQueue.getInstance().remove(self)
示例9: start
def start(self):
JobQueue.getInstance().add(self)
示例10: __init__
#.........这里部分代码省略.........
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.setName("Not supported")
empty_quality_container.addMetaDataEntry("quality_type", "normal")
empty_quality_container.addMetaDataEntry("type", "quality")
ContainerRegistry.getInstance().addContainer(empty_quality_container)
empty_quality_changes_container = copy.deepcopy(empty_container)
empty_quality_changes_container._id = "empty_quality_changes"
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)
self.waitConfigLockFile()
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)
for key in [
"dialog_load_path", # dialog_save_path is in LocalFileOutputDevicePlugin
"dialog_profile_path",
"dialog_material_path"]:
Preferences.getInstance().addPreference("local_file/%s" % key, os.path.expanduser("~/"))
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
material_bed_temperature
material_diameter
material_flow
retraction_enable
speed
speed_print
speed_travel
acceleration_print
acceleration_travel
jerk_print
jerk_travel
travel
cooling
cool_fan_enabled
support
support_enable
support_extruder_nr
support_type
support_interface_density
platform_adhesion
adhesion_type
adhesion_extruder_nr
brim_width
raft_airgap
layer_0_z_overlap
raft_surface_layers
dual
prime_tower_enable
prime_tower_size
prime_tower_position_x
prime_tower_position_y
meshfix
blackmagic
print_sequence
infill_mesh
experimental
""".replace("\n", ";").replace(" ", ""))
JobQueue.getInstance().jobFinished.connect(self._onJobFinished)
self.applicationShuttingDown.connect(self.saveSettings)
self.engineCreatedSignal.connect(self._onEngineCreated)
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))
示例11: __init__
#.........这里部分代码省略.........
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
material_bed_temperature
material_diameter
material_flow
retraction_enable
speed
speed_print
speed_travel
travel
cooling
cool_fan_enabled
support
support_enable
support_type
support_roof_density
platform_adhesion
adhesion_type
brim_width
raft_airgap
layer_0_z_overlap
raft_surface_layers
meshfix
blackmagic
print_sequence
dual
experimental
""".replace("\n", ";").replace(" ", ""))
JobQueue.getInstance().jobFinished.connect(self._onJobFinished)
self.applicationShuttingDown.connect(self.saveSettings)
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))
示例12: __init__
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
def start(self) -> None:
JobQueue.getInstance().add(self)