Discussion:
[PATCH 0 of 1] Command line arguments for host and port.
Thomas P Jakobsen
2010-04-13 18:15:22 UTC
Permalink
Here's a patch that allows users to specify player host and port
numbers via the command line.

If theres no objections, I'll push this change into VIFF in a couple
of days.

Regards,
Thomas
Thomas P Jakobsen
2010-04-13 18:15:23 UTC
Permalink
# 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

Loading...