aboutsummaryrefslogtreecommitdiff
path: root/b4/__init__.py
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-08-23 13:31:07 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-08-23 13:31:07 -0400
commita17dd19c0426b37de2262b50bfba4761b863a6d6 (patch)
treeacda242de357eee347fc86ae552c7a2d40290b3b /b4/__init__.py
parent7b8cd8047d3c17b08ad888e5bf525bdcb9cc6bbd (diff)
downloadb4-a17dd19c0426b37de2262b50bfba4761b863a6d6.tar.gz
ez: move the RESEND prefix into --resend switch
For UX reasons, make --resend a separate switch instead of operating on the --prefixes RESEND logic. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Diffstat (limited to 'b4/__init__.py')
-rw-r--r--b4/__init__.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/b4/__init__.py b/b4/__init__.py
index 4e005af..4296b10 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -916,8 +916,8 @@ class LoreMessage:
if self.date.tzinfo is None:
self.date = self.date.replace(tzinfo=datetime.timezone.utc)
- diffre = re.compile(r'^(---.*\n\+\+\+|GIT binary patch|diff --git \w/\S+ \w/\S+)', re.M | re.I)
- diffstatre = re.compile(r'^\s*\d+ file.*\d+ (insertion|deletion)', re.M | re.I)
+ diffre = re.compile(r'^(---.*\n\+\+\+|GIT binary patch|diff --git \w/\S+ \w/\S+)', flags=re.M | re.I)
+ diffstatre = re.compile(r'^\s*\d+ file.*\d+ (insertion|deletion)', flags=re.M | re.I)
# walk until we find the first text/plain part
mcharset = self.msg.get_content_charset()
@@ -2954,16 +2954,17 @@ def send_mail(smtp: Union[smtplib.SMTP, smtplib.SMTP_SSL, None], msgs: Sequence[
}
ses = get_requests_session()
res = ses.post(endpoint, json=req)
- if res.status_code == 200:
- try:
- rdata = res.json()
- if rdata.get('result') == 'success':
- return len(tosend)
- except Exception as ex: # noqa
- logger.critical('Odd response from the endpoint: %s', res.text)
-
- logger.critical('500 response from the endpoint: %s', res.text)
- return None
+ try:
+ rdata = res.json()
+ if rdata.get('result') == 'success':
+ return len(tosend)
+ except Exception as ex: # noqa
+ logger.critical('Odd response from the endpoint: %s', res.text)
+ return 0
+
+ if rdata.get('result') == 'error':
+ logger.critical('Error from endpoint: %s', rdata.get('message'))
+ return 0
if smtp:
sent = 0