def select_bitbucket_repo(self): if not self.bb_project: self.select_bitbucket_project() try: repos = self.bitbucket_api.get_project_repos(self.bb_project['key']) except BitbucketConnectionError: return self.error('Connection to bitbucket failed') except BitbucketError: return self.error('Repositories in selected project not found') if len(repos) == 0: return self.error('Repositories in selected project not found') repo = None if not self.repo and settings.BITBUCKET_REPOSITORY: repo = [repo for repo in repos if repo['name'] == settings.BITBUCKET_REPOSITORY] if repo: repo = repo[0] if not repo: print('Select repository') answer = input_list([repo['name'] for repo in repos]) repo = repos[answer - 1] self.repo = repo
def select_fix_version(self): if not self.project: self.select_jira_project() try: versions = self.jira_api.get_project_versions(self.project['key']) except JiraConnectionError: return self.error('Connection to jira failed') except JiraError: return self.error('Fix versions for selected project not found') if len(versions) == 0: return self.error('Fix versions for selected project not found') versions = [version for version in versions if not version['released']] answer = input_list([version['name'] for version in versions]) version = versions[answer - 1] self.fix_version = version
def select_jira_project(self): try: projects = self.jira_api.get_projects() except JiraConnectionError: return self.error('Connection to jira failed') except JiraError: return self.error('Projects not found') if len(projects) == 0: return self.error('Projects not found') project = None if not self.project and settings.PROJECT: project = [project for project in projects if project['key'] == settings.PROJECT] if project: project = project[0] if not project: print('Select project') answer = input_list([project['name'] for project in projects]) project = projects[answer - 1] self.project = project
def select_bitbucket_project(self): try: projects = self.bitbucket_api.get_projects() except BitbucketConnectionError: return self.error('Connection to bitbucket failed') except BitbucketError: return self.error('Projects in BitBucket not found') if len(projects) == 0: return self.error('Projects in BitBucket not found') project = None if not self.bb_project and settings.BITBUCKET_PROJECT: project = [project for project in projects if project['key'] == settings.BITBUCKET_PROJECT] if project: project = project[0] if not project: print('Select BitBucket project:') answer = input_list([project['name'] for project in projects]) project = projects[answer - 1] self.bb_project = project self.repo = None
def show_menu(self, menu): questions = [item['title'] for item in menu] answer = input_list(questions) - 1 return answer