def testSkeleton2(self): local_package_name = PLUGIN_PACKAGE_NAME package_full_name = PLUGIN_NAMESPACE + '.' + PLUGIN_PACKAGE_NAME package_dir = os.path.join(self.working_dir, package_full_name) step_dir = os.path.join( package_dir, PLUGIN_NAMESPACE, local_package_name) options = SkeletonOptions() options.setImageFile(PLUGIN_IMAGE_FILE) options.setName(PLUGIN_NAME + str(2)) options.setPackageName(local_package_name) options.setOutputDirectory(self.working_dir) options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'object') options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'number') options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'http://my.example.org/1.0/workflowstep#octopus') options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'int') s = Skeleton(options) s.write() step_file = os.path.join(step_dir, 'step.py') self.assertTrue(os.path.exists(step_file)) file_contents = open(step_file).read() self.assertIn('octopus', file_contents) self.assertIn('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', file_contents) self.assertIn('# TODO: The string must be replaced with', file_contents) self.assertIn('# TODO: Must actually set the step', file_contents) self.assertNotIn('{setidentifiercontent}', file_contents) self.assertNotIn('{serializecontent}', file_contents) self.assertNotIn('{serializesetvalues}', file_contents) resources_file = os.path.join(step_dir, 'resources_rc.py') self.assertTrue(os.path.exists(resources_file))
def testSkeleton4(self): local_package_name = PLUGIN_PACKAGE_NAME package_full_name = PLUGIN_NAMESPACE + '.' + PLUGIN_PACKAGE_NAME package_dir = os.path.join(self.working_dir, package_full_name) step_dir = os.path.join(package_dir, PLUGIN_NAMESPACE, local_package_name) options = SkeletonOptions() options.setImageFile(IMAGE_FILE_NAME) options.setIcon(QtGui.QPixmap(PLUGIN_IMAGE_FILE)) options.setName(PLUGIN_NAME + str(4)) options.setPackageName(local_package_name) options.setOutputDirectory(self.working_dir) options.addPort( 'http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'object') options.addPort( 'http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'number') options.addPort( 'http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'http://my.example.org/1.0/workflowstep#octopus') options.addPort( 'http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'int') options.addConfig('Cabbage', 'Brown') options.addConfig('Path', '') options.addConfig('Carrot', 'tis a long way down') pyside_rcc = determinePysideURccExecutable() s = Skeleton(options, pyside_rcc) s.write() self.assertTrue(os.path.exists(package_dir)) step_file = os.path.join(step_dir, 'step.py') self.assertTrue(os.path.exists(step_file)) file_contents = open(step_file).read() self.assertIn('octopus', file_contents) self.assertIn( 'http://physiomeproject.org/workflow/1.0/rdf-schema#provides', file_contents) self.assertIn('Cabbage', file_contents) self.assertIn('Carrot', file_contents) self.assertNotIn('{setidentifiercontent}', file_contents) self.assertNotIn('{serializecontent}', file_contents) self.assertNotIn('{serializesetvalues}', file_contents) resources_file = os.path.join(step_dir, 'resources_rc.py') self.assertTrue(os.path.exists(resources_file)) config_file = os.path.join(step_dir, 'configuredialog.py') self.assertTrue(os.path.exists(config_file))
def pluginWizard(self): from mapclient.tools.pluginwizard.wizarddialog import WizardDialog from mapclient.tools.pluginwizard.skeleton import Skeleton dlg = WizardDialog(self) dlg.setModal(True) if dlg.exec_() == dlg.Accepted: s = Skeleton(dlg.getOptions()) try: s.write() QtGui.QMessageBox.information(self, 'Skeleton Step', 'The Skeleton step has successfully been written to disk.') except: QtGui.QMessageBox.critical(self, 'Error Writing Step', 'There was an error writing the step, perhaps the step already exists.')
def testSkeleton1(self): local_package_name = PLUGIN_PACKAGE_NAME package_full_name = PLUGIN_NAMESPACE + '.' + PLUGIN_PACKAGE_NAME package_dir = os.path.join(self.working_dir, package_full_name) step_dir = os.path.join(package_dir, PLUGIN_NAMESPACE, local_package_name) options = SkeletonOptions() options.setImageFile(IMAGE_FILE_NAME) options.setIcon(QtGui.QPixmap(PLUGIN_IMAGE_FILE)) options.setName(PLUGIN_NAME + str(1)) options.setPackageName(local_package_name) options.setOutputDirectory(self.working_dir) options.addPort( 'http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'object') options.addPort( 'http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'http://my.example.org/1.0/workflowstep#octopus') options.addConfig('identifier', '') options.setAuthorName(AUTHOR_NAME) options.setCategory(CATEGORY) pyside_rcc = determinePysideURccExecutable() s = Skeleton(options, pyside_rcc) s.write() step_file = os.path.join(step_dir, 'step.py') self.assertTrue(os.path.exists(step_file)) file_contents = open(step_file).read() self.assertIn('octopus', file_contents) self.assertIn( 'http://physiomeproject.org/workflow/1.0/rdf-schema#provides', file_contents) self.assertIn('return self._config[', file_contents) self.assertIn('] = identifier', file_contents) self.assertIn('self._category = \'' + CATEGORY + '\'', file_contents) self.assertNotIn('{setidentifiercontent}', file_contents) self.assertNotIn('{serializecontent}', file_contents) self.assertNotIn('{serializesetvalues}', file_contents) resources_file = os.path.join(step_dir, 'resources_rc.py') self.assertTrue(os.path.exists(resources_file)) config_file = os.path.join(step_dir, 'configuredialog.py') self.assertTrue(os.path.exists(config_file)) config_contents = open(config_file).read() self.assertIn('validate', config_contents)
def testSkeleton1(self): local_package_name = PLUGIN_PACKAGE_NAME package_full_name = PLUGIN_NAMESPACE + '.' + PLUGIN_PACKAGE_NAME package_dir = os.path.join(self.working_dir, package_full_name) step_dir = os.path.join( package_dir, PLUGIN_NAMESPACE, local_package_name) options = SkeletonOptions() options.setImageFile(PLUGIN_IMAGE_FILE) options.setName(PLUGIN_NAME + str(1)) options.setPackageName(local_package_name) options.setOutputDirectory(self.working_dir) options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'object') options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'http://my.example.org/1.0/workflowstep#octopus') options.addConfig('identifier', '') options.setAuthorName(AUTHOR_NAME) options.setCategory(CATEGORY) s = Skeleton(options) s.write() step_file = os.path.join(step_dir, 'step.py') self.assertTrue(os.path.exists(step_file)) file_contents = open(step_file).read() self.assertIn('octopus', file_contents) self.assertIn('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', file_contents) self.assertIn('return self._config[', file_contents) self.assertIn('] = identifier', file_contents) self.assertIn('self._category = \'' + CATEGORY + '\'', file_contents) self.assertNotIn('{setidentifiercontent}', file_contents) self.assertNotIn('{serializecontent}', file_contents) self.assertNotIn('{serializesetvalues}', file_contents) resources_file = os.path.join(step_dir, 'resources_rc.py') self.assertTrue(os.path.exists(resources_file)) config_file = os.path.join(step_dir, 'configuredialog.py') self.assertTrue(os.path.exists(config_file)) config_contents = open(config_file).read() self.assertIn('validate', config_contents)
def testSkeleton4(self): local_package_name = PLUGIN_PACKAGE_NAME package_full_name = PLUGIN_NAMESPACE + '.' + PLUGIN_PACKAGE_NAME package_dir = os.path.join(self.working_dir, package_full_name) step_dir = os.path.join( package_dir, PLUGIN_NAMESPACE, local_package_name) options = SkeletonOptions() options.setImageFile(PLUGIN_IMAGE_FILE) options.setName(PLUGIN_NAME + str(4)) options.setPackageName(local_package_name) options.setOutputDirectory(self.working_dir) options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'object') options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'number') options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'http://my.example.org/1.0/workflowstep#octopus') options.addPort('http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'int') options.addConfig('Cabbage', 'Brown') options.addConfig('Path', '') options.addConfig('Carrot', 'tis a long way down') s = Skeleton(options) s.write() self.assertTrue(os.path.exists(package_dir)) step_file = os.path.join(step_dir, 'step.py') self.assertTrue(os.path.exists(step_file)) file_contents = open(step_file).read() self.assertIn('octopus', file_contents) self.assertIn('http://physiomeproject.org/workflow/1.0/rdf-schema#provides', file_contents) self.assertIn('Cabbage', file_contents) self.assertIn('Carrot', file_contents) self.assertNotIn('{setidentifiercontent}', file_contents) self.assertNotIn('{serializecontent}', file_contents) self.assertNotIn('{serializesetvalues}', file_contents) resources_file = os.path.join(step_dir, 'resources_rc.py') self.assertTrue(os.path.exists(resources_file)) config_file = os.path.join(step_dir, 'configuredialog.py') self.assertTrue(os.path.exists(config_file))
def _show_plugin_wizard_dialog(self): from mapclient.tools.pluginwizard.wizarddialog import WizardDialog from mapclient.tools.pluginwizard.skeleton import Skeleton om = self._model.optionsManager() dlg = WizardDialog(self) dlg.setPreviousWriteStepLocation( om.getOption(PREVIOUS_PW_WRITE_STEP_LOCATION)) dlg.setPreviousIconLocation(om.getOption(PREVIOUS_PW_ICON_LOCATION)) dlg.setModal(True) if dlg.exec_() == dlg.Accepted: om.setOption(PREVIOUS_PW_WRITE_STEP_LOCATION, dlg.getPreviousWriteStepLocation()) om.setOption(PREVIOUS_PW_ICON_LOCATION, dlg.getPreviousIconLocation()) s = Skeleton(dlg.getOptions(), self._create_qt_tools_options()) try: s.write() pm = self._model.pluginManager() pm.setReloadPlugins() self._plugin_manager_load_plugins() QtWidgets.QMessageBox.information( self, 'Skeleton Step', 'The Skeleton step has successfully been written to disk.') except Exception as e: QtWidgets.QMessageBox.critical( self, 'Error Writing Step', 'There was an error writing the step, perhaps the step already exists?' ) logger.critical(e) import os package_directory = s.getPackageDirectory() if os.path.exists(package_directory): logger.info( 'Removing partially created skeleton step "{0}"'. format(package_directory)) import shutil shutil.rmtree(package_directory)