def open_workflow(self, locator, version=None): self.close_first_vistrail_if_necessary() if self.single_document_mode and self.currentView(): self.closeVistrail() vistrail = Vistrail() try: if locator is not None: workflow = locator.load(Pipeline) action_list = [] for module in workflow.module_list: action_list.append(('add', module)) for connection in workflow.connection_list: action_list.append(('add', connection)) action = core.db.action.create_action(action_list) vistrail.add_action(action, 0L) vistrail.update_id_scope() vistrail.addTag("Imported workflow", action.id) # FIXME might need different locator? except ModuleRegistryException, e: msg = ('Cannot find module "%s" in package "%s". ' 'Make sure package is ' 'enabled in the Preferences dialog.' % \ (e._name, e._identifier)) debug.critical(msg)
def processWorkFlow(self, xmlFile): global _outputFilePath # there should probably be a call in the api for this block of code vistrail = Vistrail() locator = FileLocator(xmlFile) workflow = locator.load(Pipeline) action_list = [] for module in workflow.module_list: if module.name == 'FileSink': _outputFilePath = _tmpDir + '/cp_tmp_' + uuid.uuid4().hex + '.png' for i in xrange(module.getNumFunctions()): if 'outputPath' == module.functions[i].name: module.functions[i].params[0].strValue = _outputFilePath; action_list.append(('add', module)) for connection in workflow.connection_list: action_list.append(('add', connection)) action = core.db.action.create_action(action_list) vistrail.add_action(action, 0L) vistrail.update_id_scope() vistrail.addTag("Imported workflow", action.id) vt = get_api() # there should probably be a call in the api for this next line vt._controller.set_vistrail(vistrail, locator) vt.select_version(action.id) # Assuming that this call is synchronou vt.execute() # Close and exit vt.close_vistrail()