gerrit.wikimedia.org
Gitiles
Code ReviewSign In
gerrit.wikimedia.org / operations / software / klaxon / e01d86ede1de0341c9780a14d498ebccc7a66c15^! / .
commite01d86ede1de0341c9780a14d498ebccc7a66c15[log] [tgz]
authorChris Danis <cdanis@wikimedia.org>Wed Jan 13 16:52:19 2021 -0500
committerCDanis <cdanis@wikimedia.org>Fri Jan 15 18:30:24 2021 +0000
tree430f9cece030f156ae519695497ae59424dcc926
parentc221df5a31ebbfe6ea189cabd15c6f6d16c4d9cb [diff]
Add IRC/SAL notifications via tcpircbot. Include the magic highlight word '#page' in the notification. Change-Id: I5048994617d63bef6bac38ec449d536cb4edc4c3
diff --git a/klaxon/__init__.py b/klaxon/__init__.py index 1bd5730..b38cc21 100644 --- a/klaxon/__init__.py +++ b/klaxon/__init__.py
@@ -20,6 +20,7 @@ """ import datetime+import logging import operator import os import threading@@ -29,6 +30,7 @@ from flask import Flask, flash, redirect, render_template, request from klaxon.victorops import VictorOps+from wmflib.irc import SALSocketHandler CONFIG_DEFAULTS = { 'KLAXON_REPOSITORY': __repository__,@@ -41,6 +43,8 @@ 'KLAXON_SECRET_KEY': None, 'KLAXON_ADMIN_CONTACT_EMAIL': None, 'KLAXON_TEAM_IDS_FILTER': None, # A comma-separated list of team IDs, or unset.+ 'KLAXON_TCPIRCBOT_HOST': None,+ 'KLAXON_TCPIRCBOT_PORT': None, } @@ -80,6 +84,13 @@ admin_email=app.config['KLAXON_ADMIN_CONTACT_EMAIL'], team_ids=team_ids) + irc_logger = logging.getLogger('klaxon_irc_announce')​+ if app.config['KLAXON_TCPIRCBOT_HOST'] and app.config['KLAXON_TCPIRCBOT_PORT']:​+ irc_logger.addHandler(SALSocketHandler(app.config['KLAXON_TCPIRCBOT_HOST'],​+ int(app.config['KLAXON_TCPIRCBOT_PORT']),​+ 'klaxon'))+ irc_logger.setLevel(logging.INFO)​+ @cachetools.cached(api_cache, lock=api_lock) def fetch_victorops(): """Return the most recent incidents in reverse chronological order. Memoized."""@@ -118,7 +129,9 @@ form = request.form # TODO: validate that required fields in the form were included. summary = form['summary']- vo.send_page(summary=f"Manual page by {get_username()}: {summary}",+ headline = f"Manual #page by {get_username()}: {summary}"+ irc_logger.info(headline)+ vo.send_page(summary=headline, description=form['description']) with api_lock:
diff --git a/setup.py b/setup.py index 9b7a0ec..ffcb0ec 100644 --- a/setup.py +++ b/setup.py
@@ -18,6 +18,7 @@ ], python_requires='>=3.7', install_requires=[+ "wmflib>=0.0.6", # These are the versions packaged in Debian Buster. "requests>=2.21.0", "flask==1.0.2",
Powered by Gitiles
txt
json