summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoah <noah@656d521f-e311-0410-88e0-e7920216d269>2007-02-15 00:46:30 +0000
committernoah <noah@656d521f-e311-0410-88e0-e7920216d269>2007-02-15 00:46:30 +0000
commita72f4839714cc81176529dc77bdb734a6f6f4075 (patch)
tree7a21050073f1c08fde9a97cb39273614e04fa1d1
parenta9a31c57b50940ac8a08e4272dec223ae113d940 (diff)
downloadpexpect-a72f4839714cc81176529dc77bdb734a6f6f4075.tar.gz
Got this working again. I had messed up the CLI parsing.
git-svn-id: http://pexpect.svn.sourceforge.net/svnroot/pexpect/trunk@451 656d521f-e311-0410-88e0-e7920216d269
-rwxr-xr-xpexpect/examples/hive.py44
1 files changed, 22 insertions, 22 deletions
diff --git a/pexpect/examples/hive.py b/pexpect/examples/hive.py
index 02c0740..4d873ee 100755
--- a/pexpect/examples/hive.py
+++ b/pexpect/examples/hive.py
@@ -51,7 +51,9 @@ Anyone on your machine can see this auth information. This is not secure.
--sameuser : This flag tell Hive that you want to use the same username
for each host, but you will still be prompted for a
different password for each host.
-
+ --username=: This sets the username for all hosts. This implies --sameuser.
+ --password=: This sets the password for all hosts. This implies --password.
+
$Id$
Noah Spurrier
"""
@@ -114,7 +116,7 @@ CMD_HELP="""Hive commands are preceded by a colon : (just think of vi).
This will exit the hive shell.
"""
-def login (args):
+def login (args, cli_username=None, cli_password=None):
hive_names = []
hive = {}
for host_connect_string in args:
@@ -123,18 +125,18 @@ def login (args):
port = hcd['port']
if port == '':
port = None
- if len(hcd['username']) > 0 and not sameuser:
+ if len(hcd['username']) > 0:
username = hcd['username']
- elif cli_username == '':
- username = raw_input('username: ')
- else:
+ elif cli_username is not None:
username = cli_username
- if len(hcd['password']) > 0 and not sameauth:
- password = hcd['password']
- elif cli_password == '':
- password = getpass.getpass('password: ')
else:
+ username = raw_input('username: ')
+ if len(hcd['password']) > 0:
+ password = hcd['password']
+ elif cli_password is not None:
password = cli_password
+ else:
+ password = getpass.getpass('password: ')
print 'connecting to', hostname
try:
hive[hostname] = pxssh.pxssh()
@@ -166,21 +168,19 @@ def main ():
exit_with_usage(0)
if '--sameuser' in options:
- sameuser = True
+ cli_username = raw_input('username: ')
+ elif '--username' in options:
+ cli_username = options['--username']
else:
- sameuser = False
+ cli_username = None
if '--sameauth' in options:
- sameauth = True
- else:
- sameauth = False
- cli_username = ''
- if '--username' in options:
- cli_username = options['--username']
- cli_password = ''
- if '--password' in options:
+ cli_password = getpass.getpass('password: ')
+ elif '--password' in options:
cli_password = options['--password']
-
- (hive_names, hive) = login(args)
+ else:
+ cli_password = None
+
+ (hive_names, hive) = login(args, cli_username, cli_password)
synchronous_mode = True
target_hostnames = hive_names[:]