def _createNewWorkflow(self, workflow_dir, pmr): m = self._main_window.model().workflowManager() om = self._main_window.model().optionsManager() m.new(workflow_dir) m.setPreviousLocation(workflow_dir) if pmr: pmr_info = PMR() pmr_tool = PMRTool(pmr_info, use_external_git=om.getOption(USE_EXTERNAL_GIT)) if pmr_tool.hasAccess(): dir_name = os.path.basename(workflow_dir) try: repourl = pmr_tool.addWorkspace('Workflow: ' + dir_name, None) pmr_tool.linkWorkspaceDirToUrl(workflow_dir, repourl) except HTTPError as e: logger.exception('Error creating new') self.close() raise ClientRuntimeError( 'Error Creating New', e) else: raise ClientRuntimeError('Error Creating New', "Client doesn't have access to PMR") self._undoStack.clear() self._ui.graphicsView.setLocation(workflow_dir) self._graphicsScene.updateModel() self._update_ui()
def _commitChanges(self, workflowDir, comment, commit_local=False): committed_changes = False om = self._main_window.model().optionsManager() pmr_info = PMR() pmr_tool = PMRTool(pmr_info, use_external_git=om.getOption(USE_EXTERNAL_GIT)) try: workflow_files = [workflowDir + '/%s' % (DEFAULT_WORKFLOW_PROJECT_FILENAME), workflowDir + '/%s' % (DEFAULT_WORKFLOW_ANNOTATION_FILENAME)] for f in os.listdir(workflowDir): if f.endswith(".conf"): full_filename = os.path.join(workflowDir, f) if full_filename not in workflow_files: workflow_files.append(full_filename) pmr_tool.commitFiles(workflowDir, comment, workflow_files) # [workflowDir + '/%s' % (DEFAULT_WORKFLOW_PROJECT_FILENAME), # workflowDir + '/%s' % (DEFAULT_WORKFLOW_ANNOTATION_FILENAME)]) # XXX make/use file tracker if not commit_local: pmr_tool.pushToRemote(workflowDir) committed_changes = True except ClientRuntimeError: # handler will deal with this. raise except Exception: logger.exception('Error') raise ClientRuntimeError( 'Error Saving', 'The commit to PMR did not succeed') return committed_changes
def addHost(self, host, active=False): try: # Look for duplicates host_item = QtGui.QStandardItem(host) same_items = self._model.findItems(host) if len(same_items): raise Exception('Host "{0}" already exists'.format(host)) if self._pmr_tool.isValidHost(host): host_item.setCheckable(True) host_item.setCheckState( QtCore.Qt.Checked if active else QtCore.Qt.Unchecked) self._model.appendRow(host_item) except Exception as e: raise ClientRuntimeError('Error Adding Host', str(e))
def test_client_runtime_error(self): error = ClientRuntimeError('title', 'desc') self.assertEqual(error.title, 'title') self.assertEqual(error.description, 'desc')
def executeNext(self): try: self._main_window.execute() except WorkflowError as e: raise ClientRuntimeError('Error in workflow execution', str(e))