Permalink
Browse files

* python/mushin/command/main.py:

	* python/mushin/command/replicate.py:
	  Ask for the password if it wasn't specified for the remote host.
  • Loading branch information...
Thomas Vander Stichele
Thomas Vander Stichele committed Sep 11, 2012
1 parent c1b053a commit ce94b8471f4baec8c51780f0e1a3887cffefd801
Showing with 30 additions and 2 deletions.
  1. +7 −0 ChangeLog
  2. +2 −0 python/mushin/command/main.py
  3. +21 −2 python/mushin/command/replicate.py
View
@@ -1,3 +1,10 @@
+2012-09-11 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * python/mushin/command/main.py:
+ * python/mushin/command/replicate.py:
+
+ Ask for the password if it wasn't specified for the remote host.
+
2012-09-11 Thomas Vander Stichele <thomas at apestaart dot org>
* python/mushin/command/replicate.py:
@@ -515,4 +515,6 @@ def getNewServer(self):
return self._newServer
+ def getPassword(self, prompt='Password: '):
+ return self._stdio.getPassword(prompt=prompt)
@@ -18,7 +18,17 @@
class Add(tcommand.TwistedCommand):
summary = "Add another database to replicate with"
- usage = "REMOTE_HOST[:REMOTE_PORT][/REMOTE_DB]"
+ usage = "http://[USER[:PASSWORD]@]HOST[:PORT][/DB]"
+ description = """Set up two-way replication with another database.
+
+If you provide a username, but not a password, you will be prompted for
+the remote password.
+
+The default remote host is %s.
+The default remote port is %d.
+The default remote database is %s.
+""" % (HOST, PORT, DB)
+
@defer.inlineCallbacks
def doLater(self, args):
@@ -31,7 +41,16 @@ def doLater(self, args):
self.stdout.write('Please give a database to replicate with.\n')
return
- jane = urlrewrite.rewrite(url, hostname=HOST, port=PORT, path='/' + DB)
+ # if a username was given, but no password, ask for it
+ parsed = urlparse.urlparse(url)
+ password = None
+ if parsed.username and not parsed.password:
+ password = self.getRootCommand().getPassword(
+ prompt='Password for %s: ' % url)
+
+
+ jane = urlrewrite.rewrite(url, hostname=HOST, port=PORT,
+ password=password, path='/' + DB)
dbs = [
c.dbName,

0 comments on commit ce94b84

Please sign in to comment.