From 843db36353cf960ee4b88b6db5b1622d91c91580 Mon Sep 17 00:00:00 2001 From: Gil Forcada Codinachs Date: Thu, 4 Oct 2018 09:34:28 +0200 Subject: [PATCH] Revert "Update pull request status script to python 3.6 [4.3]" --- templates/pr-update-status.py | 76 ++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/templates/pr-update-status.py b/templates/pr-update-status.py index dec9f4bccd..f52f3538b8 100644 --- a/templates/pr-update-status.py +++ b/templates/pr-update-status.py @@ -10,22 +10,6 @@ import re import sys - -def error(message): - print( - '\n\n\n' - f'{message}' - '\n' - 'Please contact the testing team: ' - 'https://github.com/orgs/plone/teams/testing-team' - '\n' - 'Fill an issue as well: ' - 'https://github.com/plone/jenkins.plone.org/issues/new' - '\n\n\n' - ) - sys.exit(1) - - job_name = os.environ['JOB_NAME'] tests_folder = 'parts/test/testreports' if '4.3' in job_name: @@ -58,7 +42,18 @@ def error(message): try: github_api_key = os.environ['GITHUB_API_KEY'] except KeyError: - error('GITHUB_API_KEY does not exist, pull requests can not be updated.') + print( + '\n\n\n' + 'GITHUB_API_KEY does not exist, pull requests can not be updated. ' + '\n' + 'Please contact the testing team: ' + 'https://github.com/orgs/plone/teams/testing-team' + '\n' + 'Fill an issue as well: ' + 'https://github.com/plone/jenkins.plone.org/issues/new' + '\n\n\n' + ) + sys.exit(0) pull_request_urls = os.environ['PULL_REQUEST_URL'] build_url = os.environ['BUILD_URL'] @@ -73,33 +68,56 @@ def error(message): try: g_org = g.get_organization(org) except BadCredentialsException: - error('The API key used seems to not be valid any longer.') + print( + '\n\n\n' + 'The API key used seems to not be valid any longer.' + '\n' + 'Please contact the testing team: ' + 'https://github.com/orgs/plone/teams/testing-team' + '\n' + 'Fill an issue as well: ' + 'https://github.com/plone/jenkins.plone.org/issues/new' + '\n\n\n' + ) + sys.exit(0) except UnknownObjectException: - error( - f'Error on trying to get info from Pull Request {pr}' + msg = ( + '\n\n\n' + 'Error on trying to get info from Pull Request %s' '\n' - f'The organization "{org}" does not seem to exist.' + 'The organization "%s" does not seem to exist.' + '\n\n\n' ) + print(msg % (pr, org)) + sys.exit(0) # the repo where the pull request is from try: g_repo = g_org.get_repo(repo) except UnknownObjectException: - error( - f'Error on trying to get info from Pull Request {pr}' + msg = ( + '\n\n\n' + 'Error on trying to get info from Pull Request %s' '\n' - f'The repository "{repo}" does not seem to exist.' + 'The repository "%s" does not seem to exist.' + '\n\n\n' ) + print(msg % (pr, repo)) + sys.exit(0) # the pull request itself try: g_pr = g_repo.get_pull(pr_number) except UnknownObjectException: - error( - f'Error on trying to get info from Pull Request {pr}' + msg = ( + '\n\n\n' + 'Error on trying to get info from Pull Request %s' '\n' - f'The pull request num "{pr_number}" does not seem to exist.' + 'The pull request num "%s" does not seem to exist.' + '\n\n\n' ) + print(msg % (pr, pr_number)) + sys.exit(0) # get the branch branch = g_pr.head.ref @@ -113,6 +131,6 @@ def error(message): last_commit.create_status( status, target_url=build_url, - description=f'Job finished with {status} status', - context=f'Plone Jenkins CI - {job_name}', + description=u'Job finished with %s status' % status, + context='Plone Jenkins CI - {0}'.format(job_name), )