Mercurial > hg > silvermirror
comparison silvermirror/unison.py @ 15:743c920bc041
fix password prompt
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 09 May 2013 21:42:37 -0700 |
parents | 9b139702a8f9 |
children | e8752ce07aa0 |
comparison
equal
deleted
inserted
replaced
14:5f95af14b51c | 15:743c920bc041 |
---|---|
1 """ | 1 """ |
2 unison backend for silvermirror | 2 unison backend for silvermirror |
3 """ | 3 """ |
4 | 4 |
5 import pexpect | 5 import pexpect |
6 | 6 import subprocess |
7 from interface import Reflector | 7 from interface import Reflector |
8 | 8 |
9 class unison(Reflector): | 9 class unison(Reflector): |
10 | 10 |
11 def sync(self, host, resource, ignore=(), password=None, test=False): | 11 def sync(self, host, resource, ignore=(), password=None, test=False): |
14 command.extend(('-ignore', "'Name %s'" % i)) | 14 command.extend(('-ignore', "'Name %s'" % i)) |
15 | 15 |
16 command = ' '.join(command) | 16 command = ' '.join(command) |
17 print command # XXX debug -- should go to logging | 17 print command # XXX debug -- should go to logging |
18 if not test: | 18 if not test: |
19 child = pexpect.spawn(command, timeout=36000, maxread=1) | 19 if password: |
20 child.expect('password: ') | 20 child = pexpect.spawn(command, timeout=36000, maxread=1) |
21 child.sendline(password[host]) | 21 child.expect('password: ') |
22 print child.read() # XXX -> logging | 22 child.sendline(password) |
23 | 23 print child.read() # XXX -> logging |
24 else: | |
25 # XXX should not use shell=True | |
26 subprocess.call(command, shell=True) |