Permalink
Browse files

* python/mushin/command/main.py:

	* python/mushin/common/app.py:
	  Add options for host and port.  Pass them properly to
	  the servers.
  • Loading branch information...
1 parent 1cb2c61 commit 957b0261e7bae4f5811b8393d8de8cf1684c4385 Thomas Vander Stichele committed Sep 5, 2012
Showing with 26 additions and 5 deletions.
  1. +7 −0 ChangeLog
  2. +16 −3 python/mushin/command/main.py
  3. +3 −2 python/mushin/common/app.py
View
@@ -1,5 +1,12 @@
2012-09-05 Thomas Vander Stichele <thomas at apestaart dot org>
+ * python/mushin/command/main.py:
+ * python/mushin/common/app.py:
+ Add options for host and port. Pass them properly to
+ the servers.
+
+2012-09-05 Thomas Vander Stichele <thomas at apestaart dot org>
+
* python/mushin/common/logcommand.py:
Fix log depth
@@ -429,6 +429,14 @@ class GTD(tcommand.LogReactorCommand):
_newServer = None
def addOptions(self):
+ self.parser.add_option('-H', '--host',
+ action="store", dest="host",
+ default="localhost",
+ help="host to connect to (default: %default)")
+ self.parser.add_option('-P', '--port',
+ action="store", dest="port",
+ default="5984",
+ help="port to connect to (default: %default)")
self.parser.add_option('-D', '--database',
action="store", dest="database",
default="mushin",
@@ -445,9 +453,12 @@ def handleOptions(self, options):
sys.exit(0)
self.dbName = options.database
self.info("Using database %s", self.dbName)
+ self.host = options.host
+ self.info("Using host %s", self.host)
+ self.port = int(options.port)
+ self.info("Using port %d", self.port)
self._stdio = manholecmd.Stdio()
- print 'THOMAS: stdio', self._stdio
def do(self, args):
# start a command line interpreter
@@ -484,7 +495,8 @@ def getServer(self):
return self._server
try:
- self._server = couch.Server(db=self.dbName,
+ self._server = couch.Server(host=self.host, port=self.port,
+ db=self.dbName,
authenticator=InputAuthenticator(self._stdio))
except client.ResourceNotFound:
raise command.CommandExited(
@@ -496,7 +508,8 @@ def getNewServer(self):
if self._newServer:
return self._newServer
- self._newServer = app.Server(dbName=self.dbName,
+ self._newServer = app.Server(host=self.host, port=self.port,
+ dbName=self.dbName,
authenticator=InputAuthenticator(self._stdio))
return self._newServer
@@ -43,10 +43,11 @@ class Server(log.Loggable):
logCategory = 'server'
- def __init__(self, host='localhost', dbName='mushin', authenticator=None):
+ def __init__(self, host='localhost', port=5984,
+ dbName='mushin', authenticator=None):
self._host = host
self._dbName = dbName
- self._couch = client.CouchDB(host)
+ self._couch = client.CouchDB(host, port=port)
# FIXME; make this public api
self._couch._authenticator = authenticator

0 comments on commit 957b026

Please sign in to comment.