From 07d8099ff79f585457ced0991f35c062ab22f6cf Mon Sep 17 00:00:00 2001 From: Farhaan Bukhsh Date: Jul 28 2016 09:11:24 +0000 Subject: Fix styling of exception --- diff --git a/pagure/exceptions.py b/pagure/exceptions.py index 7c301dc..db3e7fa 100644 --- a/pagure/exceptions.py +++ b/pagure/exceptions.py @@ -59,6 +59,6 @@ class GitConflictsException(PagureException): pass -class HookInactive(PagureException): - """Exception raised then the hook is inactive""" +class HookInactiveException(PagureException): + ''' Exception raised when the hook is inactive. ''' pass diff --git a/pagure/lib/pagure_ci.py b/pagure/lib/pagure_ci.py index 883c81c..643f533 100644 --- a/pagure/lib/pagure_ci.py +++ b/pagure/lib/pagure_ci.py @@ -24,9 +24,9 @@ JENKINS_TRIGGER_URL = '{base}job/{project}/buildWithParameters' def process_pr(logger, cfg, pr_id, repo, branch): - """Function to process the PR, it POST the - data to the Jenkins URL to trigger build - """ + ''' Function to process the PR, it POST the + data to the Jenkins URL to trigger build. + ''' if cfg.active: post_data(logger, JENKINS_TRIGGER_URL.format( @@ -36,13 +36,13 @@ def process_pr(logger, cfg, pr_id, repo, branch): 'REPO': repo, 'BRANCH': branch}) else: - raise pagure.exceptions.HookInactive(cfg.pagure_name) + raise pagure.exceptions.HookInactiveException(cfg.pagure_name) def process_build(logger, cfg, build_id): - """Function is used to get the build info - from jenkins and flag that particular PR - """ + ''' Function is used to get the build info + from jenkins and flag that particular pull-request. + ''' if cfg.active: jenk = jenkins.Jenkins(cfg.jenkins_url) build_info = jenk.get_build_info(cfg.jenkins_name, build_id) @@ -75,11 +75,11 @@ def process_build(logger, cfg, build_id): except KeyError as exc: logger.warning('Unknown build status', exc_info=exc) else: - raise pagure.exceptions.HookInactive(cfg.pagure_name) + raise pagure.exceptions.HookInactiveException(cfg.pagure_name) def post_data(logger, *args, **kwargs): - """POST data to jenkins and reports a response""" + ''' POST data to jenkins and reports a response. ''' resp = requests.post(*args, **kwargs) logger.debug('Received response status %s', resp.status_code) if resp.status_code < 200 or resp.status_code >= 300: @@ -88,7 +88,7 @@ def post_data(logger, *args, **kwargs): def pagure_ci_flag(logger, repo, username, url, result, requestid): - """Flag the pull-request in pagure""" + ''' Flag the pull-request in pagure. ''' comment, percent = { 'SUCCESS': ('Build successful', 100), diff --git a/pagureCI/consumer.py b/pagureCI/consumer.py index 187b894..ea97f30 100644 --- a/pagureCI/consumer.py +++ b/pagureCI/consumer.py @@ -5,12 +5,13 @@ import pagure.lib from pagure.lib import pagure_ci from pagure.lib.model import BASE, Project, User from pagure import APP, SESSION +import pagure.exceptions PAGURE_MAIN_REPO = '{base}{name}.git' PAGURE_FORK_REPO = '{base}forks/{user}/{name}.git' class Integrator(fedmsg.consumers.FedmsgConsumer): - """Integrates Jenkins with Pagure""" + ''' Integrates Jenkins with Pagure. ''' topic = [ 'io.pagure.prod.pagure.pull-request.comment.added', 'io.pagure.prod.pagure.pull-request.new', @@ -24,9 +25,9 @@ class Integrator(fedmsg.consumers.FedmsgConsumer): super(Integrator, self).__init__(hub) def consume(self, msg): - """Pagure CI consumer which consumes message from + ''' Pagure CI consumer which consumes message from fedmsg and triggers Jenkins build. - """ + ''' topic, msg = msg['topic'], msg['body'] self.log.info("Received %r, %r", topic, msg.get('msg_id', None)) msg = msg['msg'] @@ -40,11 +41,11 @@ class Integrator(fedmsg.consumers.FedmsgConsumer): self.process_build(msg) except jenkins_hook.ConfigNotFound as exc: self.log.info('Unconfigured project %r', str(exc)) - except pagure_ci.HookInactive as exc: + except pagure.exceptions.HookInactiveException as exc: self.log.info('Hook Inactive for project %r', str(exc)) def trigger_build(self, msg): - """Triggers or requests to start a build in Jenkins""" + ''' Triggers or requests to start a build in Jenkins. ''' pr_id = msg['pullrequest']['id'] project = msg['pullrequest']['project']['name'] branch = msg['pullrequest']['branch_from'] @@ -57,13 +58,13 @@ class Integrator(fedmsg.consumers.FedmsgConsumer): pagure_ci.process_pr(self.log, cfg, pr_id, repo, branch) def process_build(self, msg): - """Extracts the information from the build and flag the pull-request""" + ''' Extracts the information from the build and flag the pull-request. ''' for cfg in jenkins_hook.get_configs(msg['project'], jenkins_hook.Service.JENKINS): pagure_ci.process_build(self.log, cfg, msg['build']) def get_repo(cfg, msg): - """Formats the URL for pagure repo""" + ''' Formats the URL for pagure repo. ''' url = PAGURE_MAIN_REPO if msg['pullrequest']['repo_from']['parent']: url = PAGURE_FORK_REPO @@ -74,7 +75,7 @@ def get_repo(cfg, msg): def is_rebase(msg): - """Returns Rebase if the Pull-request is rebased""" + ''' Returns Rebase if the Pull-request is rebased. ''' if msg['pullrequest']['status'] != 'Open': return False try: