Mercurial > hg > silvermirror
diff silvermirror/unify.py @ 15:743c920bc041
fix password prompt
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 09 May 2013 21:42:37 -0700 |
parents | 9b139702a8f9 |
children | 5c5edfb827b7 |
line wrap: on
line diff
--- a/silvermirror/unify.py Sun Mar 24 12:46:35 2013 -0700 +++ b/silvermirror/unify.py Thu May 09 21:42:37 2013 -0700 @@ -2,7 +2,6 @@ import getpass import os -import pexpect import socket import subprocess import sys @@ -27,9 +26,16 @@ main['basedir'] = home() main['ignore'] = main.get('ignore', '').split() # patterns to ignore - not used main['hosts'] = main.get('hosts', '').split() - main['password'] = main.get('password', 'true') # XXX not used main['timeout'] = float(main.get('timeout', '10.')) + # password prompt + truth = dict([(str(i).lower(), i) for i in (True, False)]) + password = main.get('password', 'true') + try: + main['password'] = truth[password.lower()] + except KeyError: + raise KeyError("password must be True or False (You gave: '%s')" % password) + ### resources for resource in config: @@ -71,7 +77,7 @@ s.settimeout(conf['main']['timeout']) if test: print 'Resolving %s' % host - try: + try: s.connect((host, 22)) s.close() except (socket.gaierror, socket.timeout, socket.error): @@ -115,7 +121,7 @@ os.chdir(conf['main']['basedir']) for resource in resources: for host in hosts: - reflector.sync(host, resource, resources[resource]['ignore'], pw, test) + reflector.sync(host, resource, resources[resource]['ignore'], pw.get('host'), test) os.chdir(cwd) def main(args=sys.argv[1:]): @@ -127,7 +133,7 @@ action='append', default=None) parser.add_option('--no-password', dest='password', action='store_false', default=True) - parser.add_option('--test', dest='test', + parser.add_option('--test', dest='test', action='store_true', default=False) (options, args) = parser.parse_args()