def testStepStatus(self): from mapclientplugins.imagesourcestep.widgets.configuredialog import ConfigureDialogState state = ConfigureDialogState() self.assertEqual(state.location(), '') newstate = ConfigureDialogState('here', 'there', 'anywhere', 3) self.assertEqual(newstate.identifier(), 'here') self.assertEqual(newstate.location(), 'there') self.assertEqual(newstate.pmrLocation(), 'anywhere') self.assertEqual(newstate.imageType(), 3) otherstate = ConfigureDialogState('here2', '', 'anywhere', 3) self.assertEqual(otherstate.identifier(), 'here2') self.assertEqual(otherstate.location(), '') self.assertEqual(otherstate.pmrLocation(), 'anywhere')
class ImageSourceStep(WorkflowStepMountPoint): """ A step that satisfies the step plugin duck. It describes the location of an image/a set of images. It can be used as an image source. """ def __init__(self, location): super(ImageSourceStep, self).__init__('Image Source', location) self._icon = QtGui.QImage(':/imagesource/icons/landscapeimages.png') self.addPort(('http://physiomeproject.org/workflow/1.0/rdf-schema#port', 'http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'http://physiomeproject.org/workflow/1.0/rdf-schema#images')) self._configured = False self._category = 'Source' self._state = ConfigureDialogState() def configure(self): d = ConfigureDialog(self._state, QtGui.QApplication.activeWindow().currentWidget()) d.setWorkflowLocation(self._location) d.setModal(True) if d.exec_(): self._state = d.getState() # When a PMR location is given we need to translate that into a # local path for passing into the ImageSourceData class local_dir = self._state.location() pmr_location = self._state.pmrLocation() if pmr_location and not len(local_dir): # Get login details: local_dir = self._location if not os.path.exists(local_dir): os.mkdir(local_dir) self._state.setLocation(local_dir) d.setState(self._state) if pmr_location and os.path.exists(local_dir): pmr_info = PMR() pmr_tool = PMRTool(pmr_info) pmr_tool.cloneWorkspace(pmr_location, local_dir) self._configured = d.validate() if self._configuredObserver is not None: self._configuredObserver() def getIdentifier(self): return self._state.identifier() def setIdentifier(self, identifier): self._state.setIdentifier(identifier) def serialize(self): return self._state.serialize() def deserialize(self, string): self._state.deserialize(string) d = ConfigureDialog(self._state) d.setWorkflowLocation(self._location) self._configured = d.validate() def getPortData(self, index): return ImageSourceData(self._state.identifier(), os.path.join(self._location, self._state.location()), self._state.imageType())
class ImageSourceStep(WorkflowStepMountPoint): ''' A step that satisfies the step plugin duck. It describes the location of an image/a set of images. It can be used as an image source. ''' def __init__(self, location): ''' Constructor ''' super(ImageSourceStep, self).__init__('Image Source', location) # self._location = location # self._name = 'Image source' self._icon = QtGui.QImage(':/imagesource/icons/landscapeimages.png') self.addPort(('http://physiomeproject.org/workflow/1.0/rdf-schema#port', 'http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'http://physiomeproject.org/workflow/1.0/rdf-schema#images')) self._configured = False self._category = 'Source' self._state = ConfigureDialogState() self._threadCommandManager = ThreadCommandManager() # self._threadCommandManager.registerFinishedCallback(self._threadCommandsFinished) def configure(self): d = ConfigureDialog(self._state) d.setModal(True) if d.exec_(): self.serialize(self._location) self._state = d.getState() # When a PMR location is given we need to translate that into a # local path for passing into the ImageSourceData class local_dir = self._state.location() pmr_location = self._state.pmrLocation() if pmr_location and not len(local_dir): # Get login details: local_dir = os.path.join(self._location, self._state.identifier()) if not os.path.exists(local_dir): os.mkdir(local_dir) self._state.setLocation(local_dir) d.setState(self._state) if pmr_location and os.path.exists(local_dir): pmr_tool = PMRTool() pmr_tool.cloneWorkspace(pmr_location, local_dir) self._configured = d.validate() if self._configuredObserver is not None: self._configuredObserver() def getIdentifier(self): return self._state.identifier() def setIdentifier(self, identifier): self._state.setIdentifier(identifier) def serialize(self, location): configuration_file = os.path.join(location, getConfigFilename(self._state.identifier())) s = QtCore.QSettings(configuration_file, QtCore.QSettings.IniFormat) self._state.save(s) def deserialize(self, location): configuration_file = os.path.join(location, getConfigFilename(self._state.identifier())) s = QtCore.QSettings(configuration_file, QtCore.QSettings.IniFormat) self._state.load(s) d = ConfigureDialog(self._state) self._configured = d.validate() def getPortData(self, index): return ImageSourceData(self._state.identifier(), self._state.location(), self._state.imageType())