#!/usr/bin/env python import functools import logging import phabricator import time import json from bs4 import BeautifulSoup import configfetcher import rqueue from wblogging import LoggingSetupParser parser = LoggingSetupParser( description="Read bugs from redis, format them and send them to irc", ) parser.add_argument('--raise', dest='raise_errors', action='store_true', help="Raise exceptions instead of just logging them") parser.add_argument('files', metavar='file', nargs='*', help="XACT files to parse (listen to phabricator otherwise)") parser.add_argument('--ask', dest='ask_before_push', action='store_true', help='Ask before pushing change to redis') args = parser.parse_args() logging.getLogger('requests').setLevel(logging.INFO) logger = logging.getLogger('wikibugs.wb2-phab') class Wikibugs2(object): def __init__(self, conf): """
import asyncio_redis import asyncio_redis.encoders import json import irc3 import logging import socket import channelfilter import configfetcher import messagebuilder from wblogging import LoggingSetupParser __version__ = '3.0alpha' current_host = socket.getfqdn() parser = LoggingSetupParser( description="Read bugs from redis, format them and send them to irc", ) args = parser.parse_args() logger = logging.getLogger('wikibugs.wb2-irc') class Redis2Irc(irc3.IrcBot): logging_config = {'version': 1} def __init__(self, conf, builder, chanfilter, **kwargs): """ :type conf: configfetcher.ConfigFetcher :type builder: messagebuilder.IRCMessageBuilder :type chanfilter: channelfilter.ChannelFilter """ self.channels = set(kwargs['autojoins'])
for line in ssh.stdout: logger.info(line.decode()) parsed = json.loads(line.decode()) processed = process_event(parsed) if processed: logger.info(json.dumps(processed)) try: msg = build_message(processed) channels = channel_filter(processed['repo'], processed['branch']) queue.put({ 'raw': True, 'msg': msg, 'channels': list(channels) }) except: logger.exception('Error queuing message') ssh.stdout.flush() if __name__ == '__main__': parser = LoggingSetupParser(description='Sends events from Gerrit to IRC') parser.parse_args() while True: try: main() except: logger.exception('Error, probably SSH connection dropped.')
stderr=subprocess.STDOUT ) logger.info('Opened SSH connection') for line in ssh.stdout: logger.info(line.decode()) parsed = json.loads(line.decode()) processed = process_event(parsed) if processed: logger.info(json.dumps(processed)) try: msg = build_message(processed) channels = channel_filter(processed['repo'], processed['branch']) queue.put({'raw': True, 'msg': msg, 'channels': list(channels)}) except: logger.exception('Error queuing message') ssh.stdout.flush() if __name__ == '__main__': parser = LoggingSetupParser( description='Sends events from Gerrit to IRC' ) parser.parse_args() while True: try: main() except: logger.exception('Error, probably SSH connection dropped.')
__author__ = 'Merlijn van Deen' # noqa import functools import itertools import requests import logging from wblogging import LoggingSetupParser import gerrit_rest import phabricator as legophab import config from utils import wmf_number, parse_task_number, slugify parser = LoggingSetupParser( description="Process changesets and add release tags as required", ) args = parser.parse_args() logging.getLogger('requests').setLevel(logging.INFO) logger = logging.getLogger('forrestbot') phab = legophab.Phabricator( config.PHAB_HOST, config.PHAB_USER, config.PHAB_CERT ) gerrit = gerrit_rest.GerritREST("https://gerrit.wikimedia.org/r")