Commit 7de3b409 by David Baumgold

Nicer error messaging

parent 96122fc9
...@@ -14,6 +14,10 @@ import re ...@@ -14,6 +14,10 @@ import re
from collections import OrderedDict, defaultdict from collections import OrderedDict, defaultdict
import textwrap import textwrap
import requests import requests
try:
from pygments.console import colorize
except ImportError:
colorize = lambda color, text: text
JIRA_RE = re.compile(r"\b[A-Z]{2,}-\d+\b") JIRA_RE = re.compile(r"\b[A-Z]{2,}-\d+\b")
PR_BRANCH_RE = re.compile(r"remotes/edx/pr/(\d+)") PR_BRANCH_RE = re.compile(r"remotes/edx/pr/(\d+)")
...@@ -152,14 +156,12 @@ def prs_by_email(start_ref, end_ref): ...@@ -152,14 +156,12 @@ def prs_by_email(start_ref, end_ref):
try: try:
merge = get_merge_commit(branch.commit, end_ref) merge = get_merge_commit(branch.commit, end_ref)
except DoesNotExist as err: except DoesNotExist as err:
print( message = (
"Warning: could not find merge commit for {commit}. The pull " "Warning: could not find merge commit for {commit}. "
"request containing this commit will not be included in the " "The pull request containing this commit will not be included "
"table.".format( "in the table.".format(commit=err.commit)
commit=err.commit
),
file=sys.stderr,
) )
print(colorize("red", message), file=sys.stderr)
else: else:
unordered_data[merge.author.email].add((pr_num, merge)) unordered_data[merge.author.email].add((pr_num, merge))
...@@ -187,12 +189,11 @@ def generate_table(start_ref, end_ref): ...@@ -187,12 +189,11 @@ def generate_table(start_ref, end_ref):
body = pr_info["body"] or "" body = pr_info["body"] or ""
author = pr_info["user"]["login"] author = pr_info["user"]["login"]
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
print( message = (
"Warning: could not fetch data for #{num}: {message}".format( "Warning: could not fetch data for #{num}: "
num=pull_request, message=e.message "{message}".format(num=pull_request, message=e.message)
),
file=sys.stderr,
) )
print(colorize("red", message), file=sys.stderr)
title = "?" title = "?"
body = "?" body = "?"
author = "" author = ""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment