Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: commit-queue/cq_alerts.py

Issue 135363007: Delete public commit queue to avoid confusion after move to internal repo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « commit-queue/context.py ('k') | commit-queue/creds.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5 """Send automated email alerts."""
6
7 import logging
8 import os
9 import re
10 import smtplib
11 import socket
12 import sys
13
14 ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
15 sys.path.insert(0, os.path.join(ROOT_DIR, '..', 'commit-queue-internal'))
16
17 # These come from commit-queue-internal.
18 try:
19 import alert_settings # pylint: disable=F0401
20 except ImportError:
21 alert_settings = None
22
23
24 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
25
26
27 def SendAlert(subject, message):
28 """Send an alert to troopers.
29
30 Use the golo smtp relay to prevent accidental leaks from local checkouts.
31 """
32 hostname = socket.getfqdn()
33 if (alert_settings and
34 re.match(r'cq\d?\.golo\.chromium\.org$', hostname)):
35 logging.warning('Sending alert, subject %s', subject)
36 body = """\
37 From: %s
38 To: %s
39 Subject: [cq alert] %s
40
41 host: %s
42 script dir: %s
43 cwd: %s
44 argv: %s
45
46
47 %s""" % (alert_settings.FROM_ADDRESS, ', '.join(alert_settings.TO_ADDRESSES),
48 subject, hostname, SCRIPT_DIR, os.getcwd(), sys.argv, message)
49
50 server = smtplib.SMTP(alert_settings.SMTP_RELAY)
51 server.sendmail(
52 alert_settings.FROM_ADDRESS, alert_settings.TO_ADDRESSES, body)
53 server.quit()
54 else:
55 logging.warning('\n '.join([
56 'Would send alert if running in production.',
57 'Subject: %s' % subject, ''] + message.splitlines()[:20]))
OLDNEW
« no previous file with comments | « commit-queue/context.py ('k') | commit-queue/creds.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698