Permalink
Browse files

* python/mushin/command/replicate.py:

	  Make it possible to specify host always, and either port/db
	  or both.
  • Loading branch information...
1 parent 957b026 commit 9124ba783b0a841103bc43c397ab99a34b46eaa3 Thomas Vander Stichele committed Sep 5, 2012
Showing with 24 additions and 6 deletions.
  1. +6 −0 ChangeLog
  2. +18 −6 python/mushin/command/replicate.py
View
@@ -1,5 +1,11 @@
2012-09-05 Thomas Vander Stichele <thomas at apestaart dot org>
+ * python/mushin/command/replicate.py:
+ Make it possible to specify host always, and either port/db
+ or both.
+
+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
@@ -9,28 +9,40 @@
class Add(logcommand.LogCommand):
summary = "Add another database to replicate with"
- usage = "[host]"
+ usage = "REMOTE_HOST[:REMOTE_PORT][/REMOTE_DB]"
def do(self, args):
import socket
import httplib
import cjson as json
+ c = self.getRootCommand()
# FIXME: this hardcodes our own port/server
- conn = httplib.HTTPConnection('%s:%d' % (HOST, PORT))
+ conn = httplib.HTTPConnection('%s:%d' % (c.host, c.port))
try:
jane = args[0]
except IndexError:
self.stdout.write('Please give a database to replicate with.\n')
return
- if ':' not in jane:
- jane += ':%d' % PORT
+ db = DB
+ slash = jane.find('/')
+ if slash > -1:
+ db = jane[slash + 1:]
+ jane = jane[:slash]
+ self.debug('replicating to database %s', db)
+
+ port = PORT
+ colon = jane.find(':')
+ if colon > -1:
+ port = int(jane[colon + 1:])
+ jane = jane[:colon]
+ self.debug('replicating to port %d', port)
dbs = [
- DB,
- "http://%s/%s" % (jane, DB),
+ c.dbName,
+ "http://%s:%d/%s" % (jane, port, db),
]
for source, target in [(dbs[0], dbs[1]), (dbs[1], dbs[0])]:

0 comments on commit 9124ba7

Please sign in to comment.