Make port and server config vars
authorNeil <neil@dip.sun.ac.za>
Sat, 17 Nov 2012 15:59:43 +0000 (17:59 +0200)
committerNeil <neil@dip.sun.ac.za>
Sat, 17 Nov 2012 15:59:43 +0000 (17:59 +0200)
__init__.py
irkerhook.py

index bae47ea3e9e7b898d458a7ff20b761de3df4631b..6c3f2687ec9fb13d93f8ad2f08ed8905a2a592bf 100644 (file)
@@ -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
index 4eecd2144eb2bdfa40567757112dd3e46db1a602..b18763a6dfbe19e4953e1a82375584f6b41f416a 100644 (file)
@@ -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)