From 3ad4340dea8ee06a11c02d89c5847c516cfc5862 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 17 Nov 2012 17:59:43 +0200 Subject: [PATCH] Make port and server config vars --- __init__.py | 6 ++++++ irkerhook.py | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index bae47ea..6c3f268 100644 --- a/__init__.py +++ b/__init__.py @@ -12,6 +12,8 @@ Useful configuration settings: irker_channels - The irc channels to post announcements to irker_colours - Settings for using colours in the announcements (ANSI or mIRC) + irker_server - Host for the irkerd server (localhost by default) + irker_port - port to connect to (6659 by default) """ from bzrlib.config import option_registry @@ -58,6 +60,10 @@ option_registry.register_lazy("irker_colours", "bzrlib.plugins.bzrirker.irkerhook", "opt_irker_colours") option_registry.register_lazy("irker_project", "bzrlib.plugins.bzrirker.irkerhook", "opt_irker_project") +option_registry.register_lazy("irker_server", + "bzrlib.plugins.bzrirker.irkerhook", "opt_irker_server") +option_registry.register_lazy("irker_port", + "bzrlib.plugins.bzrirker.irkerhook", "opt_irker_port") from bzrlib.hooks import install_lazy_named_hook # This causes double commit messages - investigate what we need further diff --git a/irkerhook.py b/irkerhook.py index 4eecd21..b18763a 100644 --- a/irkerhook.py +++ b/irkerhook.py @@ -8,6 +8,8 @@ import socket import sys import json +IRKER_PORT = 6659 + class IrkerSender(object): """An irker message sender.""" @@ -99,9 +101,12 @@ class IrkerSender(object): """ self.branch.lock_read() self.branch.repository.lock_read() - # These should become configurable at some point - default_server = 'localhost' - IRKER_PORT = 6659 + server = self.config.get('irker_server') + if not server: + server = 'localhost' + port = self.config.get('irker_port') + if not port: + port = IRKER_PORT try: # Do this after we have locked, to make things faster. self._setup_revision_and_revno() @@ -117,7 +122,7 @@ class IrkerSender(object): # of irker's code try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect((default_server, IRKER_PORT)) + sock.connect((server, port)) sock.sendall(message + "\n") except socket.error, e: sys.stderr.write("%s\n" % e) @@ -133,3 +138,7 @@ opt_irker_colours = Option('irker_colours', help='Colour option for irker.') opt_irker_project = Option('irker_project', help='Project name to use.') +opt_irker_server = Option('irker_server', + help='host for the irkerd server (default localhost).') +opt_irker_port = Option('irker_port', + help='port for the irkerd server (default %d)' % IRKER_PORT) -- 2.34.1