# HG changeset patch
# User Thomas P Jakobsen <***@cs.au.dk>
# Date 1271181869 -7200
# Node ID 4a6c97b250725bb5a2bdf219ae00aa8e85b0d083
# Parent 6d838b2d24a22835782d71704c9ab5c7f22eac06
Added command line option for player host and port.
Sometimes it is more convenient to specify host and port numbers of
the players as command line arguments when running VIFF itself, rather
than by editing the configuration files.
This revision enables users to override host and port numbers
specified in the configuration files by command line arguments.
diff -r 6d838b2d24a2 -r 4a6c97b25072 viff/runtime.py
--- a/viff/runtime.py Tue Mar 30 11:34:39 2010 +0200
+++ b/viff/runtime.py Tue Apr 13 20:04:29 2010 +0200
@@ -530,6 +530,12 @@
group.add_option("--no-socket-retry", action="store_true",
default=False, help="Fail rather than keep retrying "
"to connect if port is already in use.")
+ group.add_option("--host", metavar="HOST:PORT", action="append",
+ help="Override host and port of players as specified "
+ "in the configuration file. You can use this option "
+ "multiple times on the command line; the first will "
+ "override host and port of player 1, the second that "
+ "of player 2, and so forth.")
try:
# Using __import__ since we do not use the module, we are
@@ -998,6 +1004,11 @@
from viff.passive import PassiveRuntime
runtime_class = PassiveRuntime
+ if options and options.host:
+ for i in range(len(options.host)):
+ players[i + 1].host, port_str = options.host[i].rsplit(":")
+ players[i + 1].port = int(port_str)
+
if options and options.profile:
# To collect profiling information we monkey patch reactor.run
# to do the collecting. It would be nicer to simply start the