def main(): conf = configfetcher.ConfigFetcher() chanfilter = channelfilter.ChannelFilter() bot = Redis2Irc( conf=conf, builder=messagebuilder.IRCMessageBuilder(), chanfilter=chanfilter, nick=conf.get('IRC_NICK'), autojoins=['#wikimedia-cloud'], host=conf.get('IRC_SERVER'), port=6697, ssl=True, password=conf.get('IRC_PASSWORD'), realname='wikibugs2', userinfo=('Wikibugs v2.1, https://tools.wmflabs.org/wikibugs/ ,' + 'running on ' + current_host), includes=[ 'irc3.plugins.core', 'irc3.plugins.ctcp', 'irc3.plugins.autojoins', __name__, # this register MyPlugin ], ctcp={ 'finger': '{userinfo}', 'source': '{userinfo}', 'version': '{userinfo}', 'userinfo': '{userinfo}', 'ping': 'PONG', }, ) asyncio.Task(redisrunner(bot)) bot.run()
def main(): conf = configfetcher.ConfigFetcher() queue = rqueue.RedisQueue(conf.get('REDIS_QUEUE_NAME'), conf.get('REDIS_HOST')) ssh = subprocess.Popen( [ 'ssh', '*****@*****.**', '-i', os.path.join(os.path.dirname(__file__), 'id_rsa'), '-p', '29418', 'gerrit', 'stream-events' ], shell=False, bufsize=1, # line buffered stdout=subprocess.PIPE, 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()
from collections import OrderedDict import phabricator import configfetcher # work around pywikibot defaults import os pwb_path = os.path.join(os.path.split(__file__)[0], '.pywikibot') try: os.mkdir(pwb_path) except IOError: pass os.environ["PYWIKIBOT2_NO_USER_CONFIG"] = "1" os.environ["PYWIKIBOT2_DIR"] = pwb_path import pywikibot # noqa conf = configfetcher.ConfigFetcher() # Fetch projects phab = phabricator.Phabricator(conf.get('PHAB_HOST'), conf.get('PHAB_USER'), conf.get('PHAB_CERT')) projects = [] offset = 0 step = 1000 for i in range(1000): result = phab.request('project.query', { 'limit': step, 'offset': offset })['data']
if proj_channels: channels.union(proj_channels) return channels def start(self): while 1: time.sleep(0.1) useful_info = self.rqueue.get() print(useful_info) if useful_info: useful_info['matched_projects'] = list( useful_info['projects'])[:] useful_info['channel'] = '#wikimedia-labs' text = self.builder.build_message(useful_info) updated = self.channelfilter.update() if updated: print('!log tools.wikibugs Updated channels.yaml to: %s' % updated) channels = self.get_channels_for_projects( useful_info['projects']) print(','.join(channels) + ': ' + repr(text)) if __name__ == '__main__': bot = Redis2Stdout(configfetcher.ConfigFetcher(), messagebuilder.IRCMessageBuilder(), channelfilter.ChannelFilter()) bot.start()
def setUp(self): self.bugs = wikibugs.Wikibugs2( configfetcher.ConfigFetcher(str(root / "config.json.example")) )
def setUp(self): self.bugs = wikibugs.Wikibugs2( configfetcher.ConfigFetcher() )
info = {} for _type in ['old', 'new']: if trans[_type] is not None: info[_type] = self.get_user_name(trans[_type]) else: info[_type] = None useful_event_metadata['assignee'] = info logger.debug(useful_event_metadata) if not args.ask_before_push or \ input('Push? (y/N)').lower().strip() == 'y': self.rqueue.put(useful_event_metadata) if __name__ == '__main__': bugs = Wikibugs2(configfetcher.ConfigFetcher()) # Usage: # python -i wikibugs.py ~/errors/XACT-anchor/PHID-TASK-qmkysswakxnzzausyzlv # then import pdb; pdb.pm() to enter the debugger bugs.raise_errors = args.raise_errors for file in args.files: logger.info("Processing {f}".format(f=file)) from collections import OrderedDict # noqa bugs.process_event(eval(open(file).readline())) logger.info("Starting polling cycle") try: while 1: bugs.poll() time.sleep(1)