summaryrefslogtreecommitdiffstats
path: root/lldb/third_party/Python/module/pexpect-2.4/examples/passmass.py
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/third_party/Python/module/pexpect-2.4/examples/passmass.py
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadbcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
Diffstat (limited to 'lldb/third_party/Python/module/pexpect-2.4/examples/passmass.py')
-rw-r--r--lldb/third_party/Python/module/pexpect-2.4/examples/passmass.py45
1 files changed, 25 insertions, 20 deletions
diff --git a/lldb/third_party/Python/module/pexpect-2.4/examples/passmass.py b/lldb/third_party/Python/module/pexpect-2.4/examples/passmass.py
index b1e17b9cb03..3d129b67d77 100644
--- a/lldb/third_party/Python/module/pexpect-2.4/examples/passmass.py
+++ b/lldb/third_party/Python/module/pexpect-2.4/examples/passmass.py
@@ -4,7 +4,8 @@
Note that login shell prompt on remote machine must end in # or $. """
import pexpect
-import sys, getpass
+import sys
+import getpass
USAGE = '''passmass host1 host2 host3 . . .'''
COMMAND_PROMPT = '[$#] '
@@ -12,38 +13,42 @@ TERMINAL_PROMPT = r'Terminal type\?'
TERMINAL_TYPE = 'vt100'
SSH_NEWKEY = r'Are you sure you want to continue connecting \(yes/no\)\?'
+
def login(host, user, password):
- child = pexpect.spawn('ssh -l %s %s'%(user, host))
- fout = file ("LOG.TXT","wb")
- child.setlog (fout)
+ child = pexpect.spawn('ssh -l %s %s' % (user, host))
+ fout = file("LOG.TXT", "wb")
+ child.setlog(fout)
i = child.expect([pexpect.TIMEOUT, SSH_NEWKEY, '[Pp]assword: '])
- if i == 0: # Timeout
+ if i == 0: # Timeout
print 'ERROR!'
print 'SSH could not login. Here is what SSH said:'
print child.before, child.after
- sys.exit (1)
- if i == 1: # SSH does not have the public key. Just accept it.
- child.sendline ('yes')
- child.expect ('[Pp]assword: ')
+ sys.exit(1)
+ if i == 1: # SSH does not have the public key. Just accept it.
+ child.sendline('yes')
+ child.expect('[Pp]assword: ')
child.sendline(password)
# Now we are either at the command prompt or
# the login process is asking for our terminal type.
- i = child.expect (['Permission denied', TERMINAL_PROMPT, COMMAND_PROMPT])
+ i = child.expect(['Permission denied', TERMINAL_PROMPT, COMMAND_PROMPT])
if i == 0:
print 'Permission denied on host:', host
- sys.exit (1)
+ sys.exit(1)
if i == 1:
- child.sendline (TERMINAL_TYPE)
- child.expect (COMMAND_PROMPT)
+ child.sendline(TERMINAL_TYPE)
+ child.expect(COMMAND_PROMPT)
return child
# (current) UNIX password:
+
+
def change_password(child, user, oldpassword, newpassword):
- child.sendline('passwd')
- i = child.expect(['[Oo]ld [Pp]assword', '.current.*password', '[Nn]ew [Pp]assword'])
+ child.sendline('passwd')
+ i = child.expect(
+ ['[Oo]ld [Pp]assword', '.current.*password', '[Nn]ew [Pp]assword'])
# Root does not require old password, so it gets to bypass the next step.
if i == 0 or i == 1:
child.sendline(oldpassword)
@@ -53,11 +58,12 @@ def change_password(child, user, oldpassword, newpassword):
if i == 0:
print 'Host did not like new password. Here is what it said...'
print child.before
- child.send (chr(3)) # Ctrl-C
- child.sendline('') # This should tell remote passwd command to quit.
+ child.send(chr(3)) # Ctrl-C
+ child.sendline('') # This should tell remote passwd command to quit.
return
child.sendline(newpassword)
+
def main():
if len(sys.argv) <= 1:
@@ -74,7 +80,7 @@ def main():
for host in sys.argv[1:]:
child = login(host, user, password)
- if child == None:
+ if child is None:
print 'Could not login to host:', host
continue
print 'Changing password on host:', host
@@ -85,6 +91,5 @@ def main():
if __name__ == '__main__':
try:
main()
- except pexpect.ExceptionPexpect, e:
+ except pexpect.ExceptionPexpect as e:
print str(e)
-
OpenPOWER on IntegriCloud