def doStepReport(self, ws): report = {} location = self._manager.location() ws.beginGroup('nodes') node_count = ws.beginReadArray('nodelist') for i in range(node_count): ws.setArrayIndex(i) name = ws.value('name') try: step = workflowStepFactory(name, location) report[name] = 'Found' except ValueError as e: plugin_manager = self._main_window.model().pluginManager() broken_plugins = plugin_manager.get_plugin_error_names() plugin_found = False for plugin in broken_plugins: if plugin == name: report[name] = 'Broken' plugin_found = True if plugin_found: continue source_uri = ws.value('source_uri', None) if source_uri is not None: report[name] = source_uri else: report[name] = 'Not Found - {0}'.format(e) ws.endArray() ws.endGroup() return report
def dropEvent(self, event): if event.mimeData().hasFormat("image/x-workflow-step"): pieceData = event.mimeData().data("image/x-workflow-step") stream = QtCore.QDataStream(pieceData, QtCore.QIODevice.ReadOnly) hotspot = QtCore.QPoint() nameLen = stream.readUInt32() name = stream.readRawData(nameLen).decode(sys.stdout.encoding) stream >> hotspot scene = self.scene() position = self.mapToScene(event.pos() - hotspot) metastep = MetaStep(workflowStepFactory(name, self._location)) node = Node(metastep) metastep._step.registerConfiguredObserver(scene.stepConfigured) metastep._step.registerDoneExecution(scene.doneExecution) metastep._step.registerOnExecuteEntry(scene.setCurrentWidget) metastep._step.registerIdentifierOccursCount(scene.identifierOccursCount) self._undoStack.beginMacro('Add node') self._undoStack.push(CommandAdd(scene, node)) # Set the position after it has been added to the scene self._undoStack.push(CommandMove(node, position, scene.ensureItemInScene(node, position))) scene.clearSelection() node.setSelected(True) self._undoStack.endMacro() self.setFocus() event.accept() else: event.ignore()
def load_state(self, ws): self.clear() location = self._manager.location() ws.beginGroup('view') self._view_parameters = { 'scale': float(ws.value('scale', '1.0')), 'rect': ws.value('rect'), 'transform': ws.value('transform') } ws.endGroup() ws.beginGroup('nodes') nodeCount = ws.beginReadArray('nodelist') metaStepList = [] connections = [] for i in range(nodeCount): ws.setArrayIndex(i) name = ws.value('name') position = ws.value('position') selected = ws.value('selected', 'false') == 'true' identifier = ws.value('identifier') uniqueIdentifier = ws.value('unique_identifier', uuid.uuid1()) step = workflowStepFactory(name, location) step.setMainWindow(self._main_window) step.registerIdentifierOccursCount(self.identifierOccursCount) metastep = MetaStep(step) metastep.setIdentifier(identifier) metastep.setUniqueIdentifier(uniqueIdentifier) metastep.setPos(position) metastep.setSelected(selected) metaStepList.append(metastep) self.addItem(metastep) # Deserialize after adding the step to the scene, this is so # we can validate the step identifier configuration = loadConfiguration(location, identifier) step.deserialize(configuration) arcCount = ws.beginReadArray('connections') for j in range(arcCount): ws.setArrayIndex(j) connectedTo = int(ws.value('connectedTo')) connectedToIndex = int(ws.value('connectedToIndex')) connectedFromIndex = int(ws.value('connectedFromIndex')) selected = ws.value('selected', 'false') == 'true' connections.append((i, connectedFromIndex, connectedTo, connectedToIndex, selected)) ws.endArray() ws.endArray() ws.endGroup() for arc in connections: node1 = metaStepList[arc[0]] node2 = metaStepList[arc[2]] c = Connection(node1, arc[1], node2, arc[3]) c._selected = arc[4] self.addItem(c)
def is_loadable(self, ws): loadable = True location = self._manager.location() try: step_names = self._read_step_names(ws) for name in step_names: step = workflowStepFactory(name, location) except ValueError: loadable = False return loadable
def dropEvent(self, event): if event.mimeData().hasFormat("image/x-workflow-step"): piece_data = event.mimeData().data("image/x-workflow-step") stream = QtCore.QDataStream(piece_data, QtCore.QIODevice.ReadOnly) hot_spot = QtCore.QPoint() _name_len = stream.readUInt32() buf = QtCore.QByteArray() stream >> buf name = buf.data().decode() stream >> hot_spot position = self.mapToScene(event.pos()) - hot_spot scene = self.scene() # Create a step with the given name. step = workflowStepFactory(name, self._location) self.set_default_id(step) step.setMainWindow(self._main_window) step.setLocation(self._location) step.registerConfiguredObserver(scene.stepConfigured) step.registerDoneExecution(scene.doneExecution) step.registerOnExecuteEntry(scene.setCurrentWidget) step.registerIdentifierOccursCount(scene.identifierOccursCount) # Trigger a validation. step.deserialize(step.serialize()) # Prepare meta step for the graphics scene. meta_step = MetaStep(step) node = Node(meta_step) node.showStepName(self._showStepNames) self._undoStack.beginMacro('Add node') self._undoStack.push(CommandAdd(scene, node)) # Set the position after it has been added to the scene. self._undoStack.push(CommandMove(node, position, scene.ensureItemInScene(node, position))) scene.clearSelection() node.setSelected(True) self._undoStack.endMacro() self.setFocus() event.accept() else: event.ignore()
def isLoadable(self, ws): loadable = True location = self._manager.location() ws.beginGroup('nodes') nodeCount = ws.beginReadArray('nodelist') try: for i in range(nodeCount): ws.setArrayIndex(i) name = ws.value('name') step = workflowStepFactory(name, location) except ValueError: loadable = False ws.endArray() ws.endGroup() return loadable
def dropEvent(self, event): if event.mimeData().hasFormat("image/x-workflow-step"): pieceData = event.mimeData().data("image/x-workflow-step") stream = QtCore.QDataStream(pieceData, QtCore.QIODevice.ReadOnly) hotspot = QtCore.QPoint() nameLen = stream.readUInt32() # name = stream.readRawData(nameLen).decode('utf-8') if sys.version_info < (3, 0): name = stream.readRawData(nameLen).decode('utf-8') else: buf = QtCore.QByteArray() stream >> buf name = '{0}'.format(buf) stream >> hotspot scene = self.scene() position = self.mapToScene(event.pos() - hotspot) step = workflowStepFactory(name, self._location) step.setMainWindow(self._main_window) metastep = MetaStep(step) node = Node(metastep) node.showStepName(self._showStepNames) metastep._step.registerConfiguredObserver(scene.stepConfigured) metastep._step.registerDoneExecution(scene.doneExecution) metastep._step.registerOnExecuteEntry(scene.setCurrentWidget) metastep._step.registerIdentifierOccursCount( scene.identifierOccursCount) self._undoStack.beginMacro('Add node') self._undoStack.push(CommandAdd(scene, node)) # Set the position after it has been added to the scene self._undoStack.push( CommandMove(node, position, scene.ensureItemInScene(node, position))) scene.clearSelection() node.setSelected(True) self._undoStack.endMacro() self.setFocus() event.accept() else: event.ignore()
def loadState(self, ws): self.clear() location = self._manager.location() ws.beginGroup('nodes') nodeCount = ws.beginReadArray('nodelist') metaStepList = [] connections = [] for i in range(nodeCount): ws.setArrayIndex(i) name = ws.value('name') position = ws.value('position') selected = ws.value('selected', 'false') == 'true' identifier = ws.value('identifier') step = workflowStepFactory(name, location) step.registerIdentifierOccursCount(self.identifierOccursCount) step.setIdentifier(identifier) metastep = MetaStep(step) metastep._pos = position metastep._selected = selected metaStepList.append(metastep) self.addItem(metastep) # Deserialize after adding the step to the scene, this is so # we can validate the step identifier step.deserialize(location) arcCount = ws.beginReadArray('connections') for j in range(arcCount): ws.setArrayIndex(j) connectedTo = int(ws.value('connectedTo')) connectedToIndex = int(ws.value('connectedToIndex')) connectedFromIndex = int(ws.value('connectedFromIndex')) selected = ws.value('selected', 'false') == 'true' connections.append((i, connectedFromIndex, connectedTo, connectedToIndex, selected)) ws.endArray() ws.endArray() ws.endGroup() for arc in connections: node1 = metaStepList[arc[0]] node2 = metaStepList[arc[2]] c = Connection(node1, arc[1], node2, arc[3]) c._selected = arc[4] self.addItem(c)
def doStepReport(self, ws): report = {} location = self._manager.location() ws.beginGroup('nodes') node_count = ws.beginReadArray('nodelist') for i in range(node_count): ws.setArrayIndex(i) name = ws.value('name') try: step = workflowStepFactory(name, location) report[name] = 'Found' except ValueError as e: source_uri = ws.value('source_uri', None) if source_uri is not None: report[name] = source_uri else: report[name] = 'Not Found - {0}'.format(e) ws.endArray() ws.endGroup() return report