HAWQ-838. Replace python module paramiko with pexpect
Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/a1a2f2c5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/a1a2f2c5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/a1a2f2c5 Branch: refs/heads/master Commit: a1a2f2c5ceb5953c613e2a4707563e08461095ef Parents: 8712bde Author: rlei <[email protected]> Authored: Fri Aug 5 11:09:09 2016 +0800 Committer: rlei <[email protected]> Committed: Tue Aug 16 17:24:50 2016 +0800 ---------------------------------------------------------------------- pom.xml | 4 + tools/bin/Makefile | 14 +- tools/bin/gppylib/commands/base.py | 162 +--- tools/bin/gpssh-exkeys | 218 +++-- tools/bin/pythonSrc/pexpect-4.2/.gitignore | 10 + tools/bin/pythonSrc/pexpect-4.2/.travis.yml | 24 + tools/bin/pythonSrc/pexpect-4.2/DEVELOPERS.rst | 12 + tools/bin/pythonSrc/pexpect-4.2/LICENSE | 20 + tools/bin/pythonSrc/pexpect-4.2/MANIFEST.in | 6 + tools/bin/pythonSrc/pexpect-4.2/README.rst | 55 ++ tools/bin/pythonSrc/pexpect-4.2/doc/FAQ.rst | 145 ++++ tools/bin/pythonSrc/pexpect-4.2/doc/Makefile | 153 ++++ .../pythonSrc/pexpect-4.2/doc/api/fdpexpect.rst | 20 + .../bin/pythonSrc/pexpect-4.2/doc/api/index.rst | 18 + .../pythonSrc/pexpect-4.2/doc/api/pexpect.rst | 115 +++ .../pexpect-4.2/doc/api/popen_spawn.rst | 24 + .../bin/pythonSrc/pexpect-4.2/doc/api/pxssh.rst | 34 + .../pythonSrc/pexpect-4.2/doc/api/replwrap.rst | 26 + tools/bin/pythonSrc/pexpect-4.2/doc/clean.css | 103 +++ .../pythonSrc/pexpect-4.2/doc/commonissues.rst | 101 +++ tools/bin/pythonSrc/pexpect-4.2/doc/conf.py | 250 ++++++ .../bin/pythonSrc/pexpect-4.2/doc/examples.rst | 63 ++ tools/bin/pythonSrc/pexpect-4.2/doc/history.rst | 245 ++++++ tools/bin/pythonSrc/pexpect-4.2/doc/index.rst | 50 ++ tools/bin/pythonSrc/pexpect-4.2/doc/install.rst | 20 + tools/bin/pythonSrc/pexpect-4.2/doc/make.bat | 190 +++++ .../bin/pythonSrc/pexpect-4.2/doc/overview.rst | 257 ++++++ .../pythonSrc/pexpect-4.2/doc/requirements.txt | 1 + .../pexpect-4.2/doc/sphinxext/github.py | 155 ++++ tools/bin/pythonSrc/pexpect-4.2/examples/README | 89 ++ .../bin/pythonSrc/pexpect-4.2/examples/astat.py | 99 +++ .../pythonSrc/pexpect-4.2/examples/cgishell.cgi | 766 +++++++++++++++++ .../bin/pythonSrc/pexpect-4.2/examples/chess.py | 148 ++++ .../pythonSrc/pexpect-4.2/examples/chess2.py | 153 ++++ .../pythonSrc/pexpect-4.2/examples/chess3.py | 157 ++++ tools/bin/pythonSrc/pexpect-4.2/examples/df.py | 57 ++ tools/bin/pythonSrc/pexpect-4.2/examples/ftp.py | 73 ++ .../bin/pythonSrc/pexpect-4.2/examples/hive.py | 466 +++++++++++ .../pythonSrc/pexpect-4.2/examples/monitor.py | 229 ++++++ .../pythonSrc/pexpect-4.2/examples/passmass.py | 116 +++ .../pythonSrc/pexpect-4.2/examples/python.py | 49 ++ .../pythonSrc/pexpect-4.2/examples/script.py | 114 +++ .../pexpect-4.2/examples/ssh_tunnel.py | 105 +++ .../pexpect-4.2/examples/table_test.html | 106 +++ .../bin/pythonSrc/pexpect-4.2/examples/topip.py | 299 +++++++ .../pythonSrc/pexpect-4.2/examples/uptime.py | 81 ++ .../pythonSrc/pexpect-4.2/notes/my_forkpty.py | 89 ++ tools/bin/pythonSrc/pexpect-4.2/notes/notes.txt | 50 ++ .../pexpect-4.2/notes/posixmodule.c.diff | 233 ++++++ tools/bin/pythonSrc/pexpect-4.2/pexpect/ANSI.py | 351 ++++++++ tools/bin/pythonSrc/pexpect-4.2/pexpect/FSM.py | 334 ++++++++ .../pythonSrc/pexpect-4.2/pexpect/__init__.py | 85 ++ .../bin/pythonSrc/pexpect-4.2/pexpect/async.py | 78 ++ .../bin/pythonSrc/pexpect-4.2/pexpect/bashrc.sh | 5 + .../pythonSrc/pexpect-4.2/pexpect/exceptions.py | 35 + .../bin/pythonSrc/pexpect-4.2/pexpect/expect.py | 300 +++++++ .../pythonSrc/pexpect-4.2/pexpect/fdpexpect.py | 142 ++++ .../pexpect-4.2/pexpect/popen_spawn.py | 179 ++++ .../pythonSrc/pexpect-4.2/pexpect/pty_spawn.py | 806 ++++++++++++++++++ .../bin/pythonSrc/pexpect-4.2/pexpect/pxssh.py | 406 +++++++++ .../pythonSrc/pexpect-4.2/pexpect/replwrap.py | 113 +++ tools/bin/pythonSrc/pexpect-4.2/pexpect/run.py | 157 ++++ .../bin/pythonSrc/pexpect-4.2/pexpect/screen.py | 431 ++++++++++ .../pythonSrc/pexpect-4.2/pexpect/spawnbase.py | 494 +++++++++++ .../bin/pythonSrc/pexpect-4.2/pexpect/utils.py | 151 ++++ .../pexpect-4.2/requirements-testing.txt | 5 + tools/bin/pythonSrc/pexpect-4.2/setup.cfg | 5 + tools/bin/pythonSrc/pexpect-4.2/setup.py | 71 ++ .../pexpect-4.2/tests/PexpectTestCase.py | 108 +++ tools/bin/pythonSrc/pexpect-4.2/tests/README | 8 + .../pythonSrc/pexpect-4.2/tests/TESTDATA.txt | 8 + .../bin/pythonSrc/pexpect-4.2/tests/__init__.py | 25 + tools/bin/pythonSrc/pexpect-4.2/tests/adhoc.py | 36 + .../pythonSrc/pexpect-4.2/tests/alarm_die.py | 5 + tools/bin/pythonSrc/pexpect-4.2/tests/bambi.vt | 417 ++++++++++ .../tests/depricated_test_filedescriptor.py | 82 ++ .../pexpect-4.2/tests/echo_w_prompt.py | 15 + .../pythonSrc/pexpect-4.2/tests/echo_wait.py | 41 + tools/bin/pythonSrc/pexpect-4.2/tests/exit1.py | 24 + tools/bin/pythonSrc/pexpect-4.2/tests/exit667.c | 26 + .../bin/pythonSrc/pexpect-4.2/tests/fakessh/ssh | 29 + tools/bin/pythonSrc/pexpect-4.2/tests/getch.py | 50 ++ tools/bin/pythonSrc/pexpect-4.2/tests/globe.vt | 690 ++++++++++++++++ .../bin/pythonSrc/pexpect-4.2/tests/interact.py | 52 ++ .../bin/pythonSrc/pexpect-4.2/tests/list100.py | 2 + .../pythonSrc/pexpect-4.2/tests/needs_kill.py | 13 + .../pythonSrc/pexpect-4.2/tests/pexpectTest.py | 69 ++ .../tests/platform_checks/CSIGNALTEST/test.c | 90 ++ .../pexpect-4.2/tests/platform_checks/README | 2 + .../pexpect-4.2/tests/platform_checks/check.py | 77 ++ .../pexpect-4.2/tests/platform_checks/check2.py | 44 + .../platform_checks/check_control_terminal.py | 19 + .../tests/platform_checks/check_handler.py | 60 ++ .../tests/platform_checks/check_read.py | 35 + .../tests/platform_checks/check_signals.py | 67 ++ tools/bin/pythonSrc/pexpect-4.2/tests/qa.py | 26 + .../pexpect-4.2/tests/sigwinch_report.py | 50 ++ .../pythonSrc/pexpect-4.2/tests/sleep_for.py | 41 + .../pexpect-4.2/tests/swapcase_echo.py | 26 + .../bin/pythonSrc/pexpect-4.2/tests/test_FSM.py | 34 + .../pythonSrc/pexpect-4.2/tests/test_ansi.py | 228 +++++ .../pythonSrc/pexpect-4.2/tests/test_async.py | 57 ++ .../tests/test_command_list_split.py | 40 + .../pexpect-4.2/tests/test_constructor.py | 48 ++ .../pexpect-4.2/tests/test_ctrl_chars.py | 125 +++ .../pythonSrc/pexpect-4.2/tests/test_delay.py | 45 + .../pexpect-4.2/tests/test_destructor.py | 84 ++ .../pythonSrc/pexpect-4.2/tests/test_dotall.py | 43 + .../bin/pythonSrc/pexpect-4.2/tests/test_env.py | 93 +++ .../pythonSrc/pexpect-4.2/tests/test_expect.py | 583 +++++++++++++ .../pexpect-4.2/tests/test_filedescriptor.py | 72 ++ .../pexpect-4.2/tests/test_interact.py | 101 +++ .../pythonSrc/pexpect-4.2/tests/test_isalive.py | 125 +++ .../bin/pythonSrc/pexpect-4.2/tests/test_log.py | 108 +++ .../pythonSrc/pexpect-4.2/tests/test_misc.py | 346 ++++++++ .../pexpect-4.2/tests/test_missing_command.py | 38 + .../pexpect-4.2/tests/test_performance.py | 107 +++ .../pexpect-4.2/tests/test_pickling.py | 14 + .../pexpect-4.2/tests/test_popen_spawn.py | 131 +++ .../pythonSrc/pexpect-4.2/tests/test_pxssh.py | 53 ++ .../pexpect-4.2/tests/test_replwrap.py | 105 +++ .../pythonSrc/pexpect-4.2/tests/test_repr.py | 37 + .../bin/pythonSrc/pexpect-4.2/tests/test_run.py | 191 +++++ .../pexpect-4.2/tests/test_run_out_of_pty.py | 51 ++ .../pythonSrc/pexpect-4.2/tests/test_screen.py | 287 +++++++ .../pythonSrc/pexpect-4.2/tests/test_socket.py | 255 ++++++ .../pexpect-4.2/tests/test_timeout_pattern.py | 92 +++ .../pythonSrc/pexpect-4.2/tests/test_unicode.py | 187 +++++ .../pythonSrc/pexpect-4.2/tests/test_which.py | 291 +++++++ .../pythonSrc/pexpect-4.2/tests/test_winsize.py | 60 ++ .../bin/pythonSrc/pexpect-4.2/tests/tetris.data | 3 + tools/bin/pythonSrc/pexpect-4.2/tests/ticker.py | 28 + .../bin/pythonSrc/pexpect-4.2/tests/torturet.vt | 61 ++ tools/bin/pythonSrc/pexpect-4.2/tests/utils.py | 7 + .../pexpect-4.2/tools/display-fpathconf.py | 41 + .../pexpect-4.2/tools/display-maxcanon.py | 80 ++ .../pexpect-4.2/tools/display-sighandlers.py | 24 + .../pexpect-4.2/tools/display-terminalinfo.py | 209 +++++ .../tools/teamcity-coverage-report.sh | 27 + .../pexpect-4.2/tools/teamcity-runtests.sh | 64 ++ tools/bin/pythonSrc/ptyprocess-0.5.1/.gitignore | 7 + .../bin/pythonSrc/ptyprocess-0.5.1/.travis.yml | 8 + tools/bin/pythonSrc/ptyprocess-0.5.1/LICENSE | 16 + tools/bin/pythonSrc/ptyprocess-0.5.1/README.rst | 15 + .../pythonSrc/ptyprocess-0.5.1/docs/Makefile | 177 ++++ .../bin/pythonSrc/ptyprocess-0.5.1/docs/api.rst | 10 + .../bin/pythonSrc/ptyprocess-0.5.1/docs/conf.py | 266 ++++++ .../docs/images/pty_vs_popen.png | Bin 0 -> 43343 bytes .../docs/images/pty_vs_popen.svg | 759 +++++++++++++++++ .../pythonSrc/ptyprocess-0.5.1/docs/index.rst | 53 ++ tools/bin/pythonSrc/ptyprocess-0.5.1/flit.ini | 17 + .../ptyprocess-0.5.1/ptyprocess/__init__.py | 4 + .../ptyprocess-0.5.1/ptyprocess/_fork_pty.py | 77 ++ .../ptyprocess-0.5.1/ptyprocess/ptyprocess.py | 821 +++++++++++++++++++ .../ptyprocess-0.5.1/ptyprocess/util.py | 67 ++ .../ptyprocess-0.5.1/tests/__init__.py | 0 .../ptyprocess-0.5.1/tests/test_echo.py | 36 + .../tests/test_invalid_binary.py | 74 ++ .../ptyprocess-0.5.1/tests/test_preexec_fn.py | 58 ++ .../ptyprocess-0.5.1/tests/test_spawn.py | 113 +++ .../ptyprocess-0.5.1/tests/test_wait.py | 32 + 161 files changed, 19260 insertions(+), 284 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 7d67ed6..1b9a1a0 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,10 @@ <!-- PyGreSQL an open-source Python module that interfaces to a PostgreSQL database under the Python Software Foundation License --> <exclude>tools/bin/pythonSrc/PyGreSQL-4.0/**</exclude> + <!-- Open-source Python modules with ISC license --> + <exclude>tools/bin/pythonSrc/pexpect-4.2/**</exclude> + <exclude>tools/bin/pythonSrc/ptyprocess-0.5.1/**</exclude> + <!-- Open-source Python modules with MIT license --> <exclude>tools/bin/pythonSrc/PSI-0.3b2_gp/**</exclude> <exclude>tools/bin/pythonSrc/lockfile-0.9.1/**</exclude> http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/Makefile ---------------------------------------------------------------------- diff --git a/tools/bin/Makefile b/tools/bin/Makefile index 280adb9..c25a822 100644 --- a/tools/bin/Makefile +++ b/tools/bin/Makefile @@ -36,7 +36,7 @@ PYLIB_SRC=$(SRC)/pythonSrc LIB_DIR=$(SRC)/lib PYLIB_DIR=$(SRC)/ext -all: lockfile pygresql stream pychecker psi unittest2 +all: lockfile pygresql stream pychecker psi unittest2 pexpect # # Python Libraries @@ -107,6 +107,18 @@ psi: cp -r $(PYLIB_SRC)/$(PSI_DIR)/build/lib.*/psi $(PYLIB_DIR) # +# PEXPECT +# +PEXPECT_VERSION=4.2 +PEXPECT_DIR=pexpect-$(PEXPECT_VERSION) + +pexpect: + @echo "--- pexpect" + cd $(PYLIB_SRC)/$(PEXPECT_DIR)/ && CC="$(CC)" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" python setup.py build + cp -r $(PYLIB_SRC)/$(PEXPECT_DIR)/build/lib/pexpect $(PYLIB_DIR) + cp -r $(PYLIB_SRC)/ptyprocess-0.5.1/ptyprocess $(PYLIB_DIR) + +# # PYCHECKER # PYCHECKER_VERSION=0.8.18 http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/gppylib/commands/base.py ---------------------------------------------------------------------- diff --git a/tools/bin/gppylib/commands/base.py b/tools/bin/gppylib/commands/base.py index 266b9cd..877b5fd 100755 --- a/tools/bin/gppylib/commands/base.py +++ b/tools/bin/gppylib/commands/base.py @@ -44,10 +44,9 @@ from gppylib import gplog from gppylib import gpsubprocess from pygresql.pg import DB -# paramiko prints deprecation warnings which are ugly to the end-user import warnings warnings.simplefilter('ignore', DeprecationWarning) -import paramiko, getpass +import getpass logger=gplog.get_default_logger() @@ -466,165 +465,6 @@ class NakedExecutionInfo: self.sftp_local = sftp_local -class NakedExecutionPasswordMap: - def __init__(self, hostlist): - self.hostlist = hostlist - self.mapping = dict() - self.unique_passwords = set() - self.complete = False - - # this method throws exceptions on error to create a valid list - def discover(self): - - for host in self.hostlist: - client = paramiko.SSHClient() - client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - - # TRY NO PASSWORD - try: - client.connect(host) - self.mapping[host] = None - client.close() - continue # next host - except Exception, e: - pass - - try: - client.close() - except Exception, e: - pass - - # TRY EXISTING PASSWORDS - foundit = False - for passwd in self.unique_passwords: - try: - client.connect(host, password=passwd) - foundit = True - self.mapping[host] = passwd - break - except Exception, e: - pass - - if foundit: - continue - - # ASK USER - foundit = False - for attempt in range(5): - try: - passwd = getpass.getpass(' *** Enter password for %s: ' % (host), sys.stderr) - client.connect(host, password=passwd) - foundit = True - self.mapping[host] = passwd - if passwd not in self.unique_passwords: - self.unique_passwords.add(passwd) - break - except Exception, e: - pass - - try: - client.close() - except Exception, e: - pass - - if not foundit: - raise Exception("Did not get a valid password for host " + host) - - if len(self.mapping.keys()) == len(self.hostlist) and len(self.hostlist) > 0: - self.complete = True - - - -class NakedExecutionContext(LocalExecutionContext): - - def __init__(self,targetHost,stdin, nakedCommandInfo): - - LocalExecutionContext.__init__(self, stdin) - self.targetHost=targetHost - self.passwordMap = nakedCommandInfo.passwordMap - self.sftp_operation = nakedCommandInfo.sftp_operation - self.sftp_remote = nakedCommandInfo.sftp_remote - self.sftp_local = nakedCommandInfo.sftp_local - self.client = None - - def execute(self,cmd): - - self.client = paramiko.SSHClient() - self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - - try: - self.client.connect(self.targetHost, password=self.passwordMap.mapping[self.targetHost]) - except paramiko.AuthenticationException: - self.client.close() - cmd.set_results(CommandResult(1,"","password validation on %s failed" % self.targetHost,False, False)) - return - except Exception, e: - cmd.set_results(CommandResult(1,"","conection to host " + self.targetHost + " failed: " + e.__str__(),False, False)) - return - - if self.sftp_operation == NakedExecutionInfo.SFTP_NONE: - self.execute_ssh(cmd) - elif self.sftp_operation == NakedExecutionInfo.SFTP_PUT: - self.execute_sftp_put(cmd) - elif self.sftp_operation == NakedExecutionInfo.SFTP_GET: - self.execute_sftp_get(cmd) - else: - raise Exception("bad NakedExecutionInfo.sftp_operation") - - def execute_ssh(self,cmd): - - try: - stdin, stdout, stderr = self.client.exec_command(cmd.cmdStr) - rc = stdout.channel.recv_exit_status() - self.completed=True - cmd.set_results(CommandResult(rc,stdout.readlines(),stderr.readlines(),self.completed, self.halt)) - stdin.close() - stdout.close() - stderr.close() - except Exception, e: - cmd.set_results(CommandResult(1,"",e.__str__(),False, False)) - finally: - self.client.close() - - def execute_sftp_put(self, cmd): - - ftp = None - try: - ftp = self.client.open_sftp() - ftp.put(self.sftp_local, self.sftp_remote) - self.completed=True - cmd.set_results(CommandResult(0,"","",self.completed, self.halt)) - except Exception, e: - cmd.set_results(CommandResult(1,"",e.__str__(),False, False)) - finally: - ftp.close() - self.client.close() - - def execute_sftp_get(self, cmd): - - ftp = None - try: - ftp = self.client.open_sftp() - ftp.get(self.sftp_remote, self.sftp_local) - self.completed=True - cmd.set_results(CommandResult(0,"","",self.completed, self.halt)) - except Exception, e: - cmd.set_results(CommandResult(1,"",e.__str__(),False, False)) - finally: - ftp.close() - self.client.close() - - def interrupt(self, cmd): - self.halt=True - self.client.close() - cmd.set_results(CommandResult(1,"","command on host " + self.targetHost + " interrupted ", False, False)) - - def cancel(self, cmd): - self.client.close() - cmd.set_results(CommandResult(1,"","command on host " + self.targetHost + " canceled ", False, False)) - - - class RemoteExecutionContext(LocalExecutionContext): trail = set() http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/gpssh-exkeys ---------------------------------------------------------------------- diff --git a/tools/bin/gpssh-exkeys b/tools/bin/gpssh-exkeys index c02c980..374e536 100755 --- a/tools/bin/gpssh-exkeys +++ b/tools/bin/gpssh-exkeys @@ -61,10 +61,10 @@ warnings.simplefilter('ignore', DeprecationWarning) sys.path.append(sys.path[0] + '/lib') try: - import paramiko import getopt, time, getpass, logging import tempfile, filecmp import array, socket, subprocess + import pexpect from gppylib.commands import unix from gppylib.util import ssh_utils from gppylib.gpparseopts import OptParser @@ -183,16 +183,31 @@ class Host: return False - def tryParamikoConnect(self, client, pwd = None, silence = False): + def password_ssh(self, host, cmd, user, password, timeout=5): + """SSH to a host using the supplied password and executes a command.""" + fname = tempfile.mktemp() + fout = open(fname, 'w') + + options = '-q -oPasswordAuthentication=yes -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oPubkeyAuthentication=no' + ssh_cmd = 'ssh %s@%s %s "%s"' % (user, host, options, cmd) + try: - client.connect(self.m_host, password=pwd) - return True - except paramiko.AuthenticationException: - if not silence: print >> sys.stderr, '[ERROR %s] bad password' % (self.m_host) - return False - except paramiko.SSHException, e: - if not silence: print >> sys.stderr, '[ERROR %s] %s' % (self.m_host, str(e)) - return False + child = pexpect.spawn(ssh_cmd, timeout=timeout) + child.expect(['password: ']) + child.sendline(password) + child.logfile = fout + child.expect(pexpect.EOF) + child.close() + fout.close() + except: + pass + + fin = open(fname, 'r') + stdout = fin.read() + fin.close() + + return stdout, child.exitstatus + def sendLocalID(self, ID, passwd, tempDir): ''' @@ -201,116 +216,78 @@ class Host: id_rsa.pub files are obtained from the target host. These files are placed in <tempDir>/<self.m_host> ''' - p = None - cin = cout = cerr = None - try: - p = paramiko.SSHClient() - p.load_system_host_keys() - ok = self.tryParamikoConnect(p, silence = True) - if not ok: - for pwd in passwd: - ok = self.tryParamikoConnect(p, pwd, silence = True) - if ok: break - while not ok: + cur_user = getpass.getuser() + password_less = True + cmd = 'true' + rc = os.system("ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oPubkeyAuthentication=yes %s \"%s\"" % (self.m_host, cmd)) + if rc != 0: + password_less = False + for pwd in passwd: + output, rc = self.password_ssh(self.m_host, cmd, cur_user, pwd) + if rc == 0: + cur_password = pwd + break + while rc != 0: print >> sys.stderr, ' ***' - pwd = getpass.getpass(' *** Enter password for %s: ' % (self.m_host), sys.stderr) - if pwd: ok = self.tryParamikoConnect(p, pwd) - if ok: passwd.append(pwd) - - # Create .ssh directory and ensure content meets permission requirements - # for password-less SSH - # - # note: we touch .ssh/iddummy.pub just before the chmod operations to - # ensure the wildcard matches at least one file. - cmd = ('mkdir -p .ssh; ' + - 'chmod 0700 .ssh; ' + - 'touch .ssh/authorized_keys; ' + - 'touch .ssh/known_hosts; ' + - 'touch .ssh/config; ' + - 'touch .ssh/iddummy.pub; ' + - 'chmod 0600 .ssh/auth* .ssh/id*; ' + - 'chmod 0644 .ssh/id*.pub .ssh/config') + pwd = getpass.getpass(' *** Enter password for %s: ' % self.m_host, sys.stderr) + if pwd: + output, rc = self.password_ssh(self.m_host, cmd, cur_user, pwd) + if rc == 0: + cur_password = pwd + passwd.append(pwd) + + # Create .ssh directory and ensure content meets permission requirements + # for password-less SSH + # + # note: we touch .ssh/iddummy.pub just before the chmod operations to + # ensure the wildcard matches at least one file. + cmd = ('mkdir -p .ssh; ' + + 'chmod 0700 .ssh; ' + + 'touch .ssh/authorized_keys; ' + + 'touch .ssh/known_hosts; ' + + 'touch .ssh/config; ' + + 'touch .ssh/iddummy.pub; ' + + 'chmod 0600 .ssh/auth* .ssh/id*; ' + + 'chmod 0644 .ssh/id*.pub .ssh/config') + if GV.opt['-v']: print '[INFO %s]: %s' % (self.m_host, cmd) + if password_less: + rc = os.system("ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oPubkeyAuthentication=yes %s \"%s\"" % (self.m_host, cmd)) + else: + output, rc = self.password_ssh(self.m_host, cmd, cur_user, cur_password) + + if rc != 0: + print "Set permission for ssh configuration files on host %s failed, exit." % self.m_host + return False + + # If tempDir is specified, obtain a copy of the ssh + # files that should be preserved for existing hosts. + if tempDir: + cmd = 'cd .ssh && tar cf %s.tar authorized_keys known_hosts id_rsa.pub' % self.m_host if GV.opt['-v']: print '[INFO %s]: %s' % (self.m_host, cmd) - (cin, cout, cerr) = p.exec_command(cmd) - cin.close(); - exitStatus = cout.channel.recv_exit_status() - if GV.opt['-v']: - print '[INFO %s]: exit status=%s' % (self.m_host, exitStatus) - if cout.channel.recv_ready(): - print '[INFO] stdout:' - for line in cout: - print ' ', line.rstrip() - if cout.channel.recv_stderr_ready(): - print '[INFO] stderr:' - for line in cerr: - print ' ', line.rstrip() - print - cout.close(); cerr.close() - - # If tempDir is specified, obtain a copy of the ssh - # files that should be preserved for existing hosts. - if tempDir: - cmd = 'cd .ssh && tar cf - authorized_keys known_hosts id_rsa.pub' - if GV.opt['-v']: print '[INFO %s]: %s' % (self.m_host, cmd) - (cin, cout, cerr) = p.exec_command(cmd) - cin.close() - - # Grab the tar stream from stdout - tarfile = open(os.path.join(tempDir, '%s.tar' % self.m_host), 'wb') - buf = array.array('B') - try: - # The paramiko.SSHClient.exec_command stdout file read() - # method returns a string. This string must be converted - # back to binary before writing to the local tar file. - while True: - chunk = cout.read(4096) - if not chunk: break - buf.fromstring(chunk) - buf.tofile(tarfile) - del buf[:] - finally: - if tarfile: - tarfile.close() - exitStatus = cout.channel.recv_exit_status() - cout.close() - if exitStatus != 0: - print >> sys.stderr, ('[WARNING %s] cannot fetch existing authentication files: tar rc=%s;' - % (self.m_host, exitStatus)) - for line in cerr: - print >> sys.stderr, ' ', line.rstrip() - print >> sys.stderr, ' One or more existing authentication files may be replaced on %s' % self.m_host - - cerr.close() - - # The tar file content is expected to be extacted by the caller. Doing it - # here causes Paramiko Transport grief on Linux systems. (The Event.wait() - # used can be interrupted by the SIGCHLD signal popped by destruction of the - # process spawned to run the tar command -- Paramiko isn't ready for that to - # happen. - - # Append the ID to authorized_keys; this is *temporary* -- - # authorized_keys is expected to be replaced when the master - # .ssh content is shipped to the host. - cmd = 'echo \"%s\" >> .ssh/authorized_keys && echo ok ok ok' % ID + if password_less: + rc = os.system("ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oPubkeyAuthentication=yes %s \"%s\"" % (self.m_host, cmd)) + else: + output, rc = self.password_ssh(self.m_host, cmd, cur_user, cur_password) + if rc != 0: + print "Backup ssh configuration files on host %s failed, exit." % self.m_host + return False + + # Append local ID to authorized_keys + if not password_less: + cmd = 'echo \"%s\" >> .ssh/authorized_keys && echo ok ok ok; chmod 0600 .ssh/authorized_keys;' % ID if GV.opt['-v']: print '[INFO %s]: %s' % (self.m_host, cmd) - (cin, cout, cerr) = p.exec_command(cmd) - cin.close() - line = cout.readline() - ok = (line.find('ok ok ok') >= 0) - if not ok: - print >> sys.stderr, '[ERROR] cannot append local ID to authorized_keys on %s' % self.m_host - for line in cerr: - print >> sys.stderr, ' ', line.rstrip() - print >> sys.stderr - cout.close(); cerr.close() - - return ok - - finally: - if cin: cin.close() - if cout: cout.close() - if cerr: cerr.close() - if p and p._transport: p.close() + output, rc = self.password_ssh(self.m_host, cmd, cur_user, cur_password) + if rc != 0: + print "Append local ID to authorized_keys on %s failed, exit." % self.m_host + return False + + if tempDir: + rc = os.system("scp -q -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oPubkeyAuthentication=yes %s:%s/.ssh/%s.tar %s/" % (self.m_host, os.environ['HOME'], self.m_host, tempDir)) + if rc != 0: + print "Copy backup file %s.tar from remote host %s failed, exit." % (self.m_host, self.m_host) + return False + + return True def popen(self, cmd): @@ -522,12 +499,8 @@ try: debugLog = logging.StreamHandler() debugLog.setLevel(logging.DEBUG) debugLog.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(module)s:%(funcName)s:%(lineno)d - %(levelname)s - %(message)s")) - paramiko_logger = logging.getLogger('paramiko.transport') - paramiko_logger.addHandler(debugLog) - paramiko_logger.setLevel(logging.DEBUG) else: nullFile = logging.FileHandler('/dev/null') - logging.getLogger('paramiko.transport').addHandler(nullFile) parseCommandLine() @@ -755,7 +728,7 @@ try: # # The last step for each host is ensuring that password-less access # from the current user is enabled. This is done using SSH rather - # than Paramiko to ensure that normal SSH processing is possible. + # than pexpect to ensure that normal SSH processing is possible. # print; print '[STEP 3 of 5] authorize current user on remote hosts' # serial errmsg = None @@ -767,6 +740,7 @@ try: send_local_id = False try: send_local_id = h.sendLocalID(localID, GV.passwd, tempDir if isExistingHost else None) + #print "Send local id is: %s" % send_local_id except socket.error, e: errmsg = '[ERROR %s] %s' % (h.host(), e) print >> sys.stderr, errmsg http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/.gitignore ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/.gitignore b/tools/bin/pythonSrc/pexpect-4.2/.gitignore new file mode 100644 index 0000000..914c903 --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/.gitignore @@ -0,0 +1,10 @@ +*.pyc +doc/_build +tests/log +build/ +dist/ +MANIFEST +*~ +.coverage* +htmlcov +*.egg-info/ http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/.travis.yml ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/.travis.yml b/tools/bin/pythonSrc/pexpect-4.2/.travis.yml new file mode 100644 index 0000000..251dfaa --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/.travis.yml @@ -0,0 +1,24 @@ +language: python + +python: + - 2.7 + - 3.3 + - 3.4 + - 3.5 + - pypy + +install: + - export PYTHONIOENCODING=UTF8 + - pip install coveralls pytest-cov ptyprocess + +script: + - ./tools/display-sighandlers.py + - ./tools/display-terminalinfo.py + - py.test --cov pexpect --cov-config .coveragerc + +after_success: + - coverage combine + - coveralls + +# Use new Travis stack, should be faster +sudo: false http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/DEVELOPERS.rst ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/DEVELOPERS.rst b/tools/bin/pythonSrc/pexpect-4.2/DEVELOPERS.rst new file mode 100644 index 0000000..bf2bb9f --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/DEVELOPERS.rst @@ -0,0 +1,12 @@ +To run the tests, use `py.test <http://pytest.org/latest/>`_:: + + py.test tests + +The tests are all located in the tests/ directory. To add a new unit +test all you have to do is create the file in the tests/ directory with a +filename in this format:: + + test_*.py + +New test case classes may wish to inherit from ``PexpectTestCase.PexpectTestCase`` +in the tests directory, which sets up some convenient functionality. http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/LICENSE ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/LICENSE b/tools/bin/pythonSrc/pexpect-4.2/LICENSE new file mode 100644 index 0000000..754db5a --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/LICENSE @@ -0,0 +1,20 @@ +ISC LICENSE + + This license is approved by the OSI and FSF as GPL-compatible. + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2013-2014, Pexpect development team + Copyright (c) 2012, Noah Spurrier <[email protected]> + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/MANIFEST.in ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/MANIFEST.in b/tools/bin/pythonSrc/pexpect-4.2/MANIFEST.in new file mode 100644 index 0000000..32c72ba --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/MANIFEST.in @@ -0,0 +1,6 @@ +recursive-include doc * +prune doc/_build +recursive-include examples * +include .coveragerc README.rst LICENSE pexpect/bashrc.sh +recursive-include tests * +global-exclude __pycache__ *.pyc *~ http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/README.rst ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/README.rst b/tools/bin/pythonSrc/pexpect-4.2/README.rst new file mode 100644 index 0000000..f03be78 --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/README.rst @@ -0,0 +1,55 @@ +.. image:: https://travis-ci.org/pexpect/pexpect.png?branch=master + :target: https://travis-ci.org/pexpect/pexpect + :align: right + :alt: Build status + +Pexpect is a Pure Python Expect-like module + +Pexpect makes Python a better tool for controlling other applications. + +Pexpect is a pure Python module for spawning child applications; controlling +them; and responding to expected patterns in their output. Pexpect works like +Don Libes' Expect. Pexpect allows your script to spawn a child application and +control it as if a human were typing commands. + +Pexpect can be used for automating interactive applications such as ssh, ftp, +passwd, telnet, etc. It can be used to a automate setup scripts for duplicating +software package installations on different servers. It can be used for +automated software testing. Pexpect is in the spirit of Don Libes' Expect, but +Pexpect is pure Python. + +The main features of Pexpect require the pty module in the Python standard +library, which is only available on Unix-like systems. Some featuresâwaiting +for patterns from file descriptors or subprocessesâare also available on +Windows. + +If you want to work with the development version of the source code then please +read the DEVELOPERS.rst document in the root of the source code tree. + +Free, open source, and all that good stuff. + +You can install Pexpect using pip:: + + pip install pexpect + +`Docs on ReadTheDocs <https://pexpect.readthedocs.io/>`_ + +PEXPECT LICENSE:: + + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2013-2014, Pexpect development team + Copyright (c) 2012, Noah Spurrier <[email protected]> + + PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY + PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE + COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +This license is approved by the OSI and FSF as GPL-compatible. http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/doc/FAQ.rst ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/doc/FAQ.rst b/tools/bin/pythonSrc/pexpect-4.2/doc/FAQ.rst new file mode 100644 index 0000000..1964b12 --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/doc/FAQ.rst @@ -0,0 +1,145 @@ +FAQ +=== + +**Q: Where can I get help with pexpect? Is there a mailing list?** + +A: You can use the `pexpect tag on Stackoverflow <http://stackoverflow.com/questions/tagged/pexpect>`__ +to ask questions specifically related to Pexpect. For more general Python +support, there's the python-list_ mailing list, and the `#python`_ +IRC channel. Please refrain from using github for general +python or systems scripting support. + +.. _python-list: https://mail.python.org/mailman/listinfo/python-list +.. _#python: https://www.python.org/community/irc/ + +**Q: Why don't shell pipe and redirect (| and >) work when I spawn a command?** + +A: Remember that Pexpect does NOT interpret shell meta characters such as +redirect, pipe, or wild cards (``>``, ``|``, or ``*``). That's done by a shell not +the command you are spawning. This is a common mistake. If you want to run a +command and pipe it through another command then you must also start a shell. +For example:: + + child = pexpect.spawn('/bin/bash -c "ls -l | grep LOG > log_list.txt"') + child.expect(pexpect.EOF) + +The second form of spawn (where you pass a list of arguments) is useful in +situations where you wish to spawn a command and pass it its own argument list. +This can make syntax more clear. For example, the following is equivalent to the +previous example:: + + shell_cmd = 'ls -l | grep LOG > log_list.txt' + child = pexpect.spawn('/bin/bash', ['-c', shell_cmd]) + child.expect(pexpect.EOF) + +**Q: The `before` and `after` properties sound weird.** + +A: This is how the -B and -A options in grep works, so that made it +easier for me to remember. Whatever makes my life easier is what's best. +Originally I was going to model Pexpect after Expect, but then I found +that I didn't actually like the way Expect did some things. It was more +confusing. The `after` property can be a little confusing at first, +because it will actually include the matched string. The `after` means +after the point of match, not after the matched string. + +**Q: Why not just use Expect?** + +A: I love it. It's great. I has bailed me out of some real jams, but I +wanted something that would do 90% of what I need from Expect; be 10% of +the size; and allow me to write my code in Python instead of TCL. +Pexpect is not nearly as big as Expect, but Pexpect does everything I +have ever used Expect for. + +.. _whynotpipe: + +**Q: Why not just use a pipe (popen())?** + +A: A pipe works fine for getting the output to non-interactive programs. +If you just want to get the output from ls, uname, or ping then this +works. Pipes do not work very well for interactive programs and pipes +will almost certainly fail for most applications that ask for passwords +such as telnet, ftp, or ssh. + +There are two reasons for this. + +* First an application may bypass stdout and print directly to its + controlling TTY. Something like SSH will do this when it asks you for + a password. This is why you cannot redirect the password prompt because + it does not go through stdout or stderr. + +* The second reason is because most applications are built using the C + Standard IO Library (anything that uses ``#include <stdio.h>``). One + of the features of the stdio library is that it buffers all input and + output. Normally output is line buffered when a program is printing to + a TTY (your terminal screen). Everytime the program prints a line-feed + the currently buffered data will get printed to your screen. The + problem comes when you connect a pipe. The stdio library is smart and + can tell that it is printing to a pipe instead of a TTY. In that case + it switches from line buffer mode to block buffered. In this mode the + currently buffered data is flushed when the buffer is full. This + causes most interactive programs to deadlock. Block buffering is more + efficient when writing to disks and pipes. Take the situation where a + program prints a message ``"Enter your user name:\n"`` and then waits + for you type type something. In block buffered mode, the stdio library + will not put the message into the pipe even though a linefeed is + printed. The result is that you never receive the message, yet the + child application will sit and wait for you to type a response. Don't + confuse the stdio lib's buffer with the pipe's buffer. The pipe buffer + is another area that can cause problems. You could flush the input + side of a pipe, whereas you have no control over the stdio library buffer. + +More information: the Standard IO library has three states for a +``FILE *``. These are: _IOFBF for block buffered; _IOLBF for line buffered; +and _IONBF for unbuffered. The STDIO lib will use block buffering when +talking to a block file descriptor such as a pipe. This is usually not +helpful for interactive programs. Short of recompiling your program to +include fflush() everywhere or recompiling a custom stdio library there +is not much a controlling application can do about this if talking over +a pipe. + +The program may have put data in its output that remains unflushed +because the output buffer is not full; then the program will go and +deadlock while waiting for input -- because you never send it any +because you are still waiting for its output (still stuck in the STDIO's +output buffer). + +The answer is to use a pseudo-tty. A TTY device will force line +buffering (as opposed to block buffering). Line buffering means that you +will get each line when the child program sends a line feed. This +corresponds to the way most interactive programs operate -- send a line +of output then wait for a line of input. + +I put "answer" in quotes because it's ugly solution and because there is +no POSIX standard for pseudo-TTY devices (even though they have a TTY +standard...). What would make more sense to me would be to have some way +to set a mode on a file descriptor so that it will tell the STDIO to be +line-buffered. I have investigated, and I don't think there is a way to +set the buffered state of a child process. The STDIO Library does not +maintain any external state in the kernel or whatnot, so I don't think +there is any way for you to alter it. I'm not quite sure how this +line-buffered/block-buffered state change happens internally in the +STDIO library. I think the STDIO lib looks at the file descriptor and +decides to change behavior based on whether it's a TTY or a block file +(see isatty()). + +I hope that this qualifies as helpful. Don't use a pipe to control +another application. + +**Q: Can I do screen scraping with this thing?** + +A: That depends. If your application just does line-oriented output then +this is easy. If a program emits many terminal sequences, from video +attributes to screen addressing, such as programs using curses, then +it may become very difficult to ascertain what text is displayed on a screen. + +We suggest using the `pyte <https://github.com/selectel/pyte>`_ library to +screen-scrape. The module :mod:`pexpect.ANSI` released with previous versions +of pexpect is now marked deprecated and may be removed in the future. + +**Q: I get strange behavior with pexect and gevent** + +A: Pexpect uses fork(2), exec(2), select(2), waitpid(2), and implements its +own selector in expect family of calls. pexpect has been known to misbehave +when paired with gevent. A solution might be to isolate your pexpect +dependent code from any frameworks that manipulate event selection behavior +by running it in an another process entirely. http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/doc/Makefile ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/doc/Makefile b/tools/bin/pythonSrc/pexpect-4.2/doc/Makefile new file mode 100644 index 0000000..ced8a68 --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/doc/Makefile @@ -0,0 +1,153 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make <target>' where <target> is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Pexpect.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Pexpect.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/Pexpect" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Pexpect" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/doc/api/fdpexpect.rst ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/doc/api/fdpexpect.rst b/tools/bin/pythonSrc/pexpect-4.2/doc/api/fdpexpect.rst new file mode 100644 index 0000000..3ddf2cd --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/doc/api/fdpexpect.rst @@ -0,0 +1,20 @@ +fdpexpect - use pexpect with a file descriptor +============================================== + +.. automodule:: pexpect.fdpexpect + +fdspawn class +------------- + +.. autoclass:: fdspawn + :show-inheritance: + + .. automethod:: __init__ + .. automethod:: isalive + .. automethod:: close + + .. method:: expect + expect_exact + expect_list + + As :class:`pexpect.spawn`. http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/doc/api/index.rst ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/doc/api/index.rst b/tools/bin/pythonSrc/pexpect-4.2/doc/api/index.rst new file mode 100644 index 0000000..5277d1c --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/doc/api/index.rst @@ -0,0 +1,18 @@ +API documentation +================= + +.. toctree:: + :maxdepth: 2 + + pexpect + fdpexpect + popen_spawn + replwrap + pxssh + +The modules ``pexpect.screen`` and ``pexpect.ANSI`` have been deprecated in +Pexpect version 4. They were separate from the main use cases for Pexpect, and +there are better maintained Python terminal emulator packages, such as +`pyte <https://pypi.python.org/pypi/pyte>`__. +These modules are still present for now, but we don't advise using them in new +code. http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/doc/api/pexpect.rst ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/doc/api/pexpect.rst b/tools/bin/pythonSrc/pexpect-4.2/doc/api/pexpect.rst new file mode 100644 index 0000000..79bbcef --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/doc/api/pexpect.rst @@ -0,0 +1,115 @@ +Core pexpect components +======================= + +.. automodule:: pexpect + +spawn class +----------- + +.. autoclass:: spawn + + .. automethod:: __init__ + .. automethod:: expect + .. automethod:: expect_exact + .. automethod:: expect_list + .. automethod:: compile_pattern_list + .. automethod:: send + .. automethod:: sendline + .. automethod:: write + .. automethod:: writelines + .. automethod:: sendcontrol + .. automethod:: sendeof + .. automethod:: sendintr + .. automethod:: read + .. automethod:: readline + .. automethod:: read_nonblocking + .. automethod:: eof + .. automethod:: interact + + .. attribute:: logfile + logfile_read + logfile_send + + Set these to a Python file object (or :data:`sys.stdout`) to log all + communication, data read from the child process, or data sent to the child + process. + + .. note:: + + With :class:`spawn` in bytes mode, the log files should be open for + writing binary data. In unicode mode, they should + be open for writing unicode text. See :ref:`unicode`. + +Controlling the child process +````````````````````````````` + +.. class:: spawn + + .. automethod:: kill + .. automethod:: terminate + .. automethod:: isalive + .. automethod:: wait + .. automethod:: close + .. automethod:: getwinsize + .. automethod:: setwinsize + .. automethod:: getecho + .. automethod:: setecho + .. automethod:: waitnoecho + + .. attribute:: pid + + The process ID of the child process. + + .. attribute:: child_fd + + The file descriptor used to communicate with the child process. + +.. _unicode: + +Handling unicode +```````````````` + +By default, :class:`spawn` is a bytes interface: its read methods return bytes, +and its write/send and expect methods expect bytes. If you pass the *encoding* +parameter to the constructor, it will instead act as a unicode interface: +strings you send will be encoded using that encoding, and bytes received will +be decoded before returning them to you. In this mode, patterns for +:meth:`~spawn.expect` and :meth:`~spawn.expect_exact` should also be unicode. + +.. versionchanged:: 4.0 + + :class:`spawn` provides both the bytes and unicode interfaces. In Pexpect + 3.x, the unicode interface was provided by a separate ``spawnu`` class. + +For backwards compatibility, some Unicode is allowed in bytes mode: the +send methods will encode arbitrary unicode as UTF-8 before sending it to the +child process, and its expect methods can accept ascii-only unicode strings. + +.. note:: + + Unicode handling with pexpect works the same way on Python 2 and 3, despite + the difference in names. I.e.: + + - Bytes mode works with ``str`` on Python 2, and :class:`bytes` on Python 3, + - Unicode mode works with ``unicode`` on Python 2, and :class:`str` on Python 3. + +run function +------------ + +.. autofunction:: run + +Exceptions +---------- + +.. autoclass:: EOF + +.. autoclass:: TIMEOUT + +.. autoclass:: ExceptionPexpect + +Utility functions +----------------- + +.. autofunction:: which + +.. autofunction:: split_command_line http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/doc/api/popen_spawn.rst ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/doc/api/popen_spawn.rst b/tools/bin/pythonSrc/pexpect-4.2/doc/api/popen_spawn.rst new file mode 100644 index 0000000..64cae15 --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/doc/api/popen_spawn.rst @@ -0,0 +1,24 @@ +popen_spawn - use pexpect with a piped subprocess +================================================= + +.. automodule:: pexpect.popen_spawn + +PopenSpawn class +---------------- + +.. autoclass:: PopenSpawn + + .. automethod:: __init__ + .. automethod:: send + .. automethod:: sendline + .. automethod:: write + .. automethod:: writelines + .. automethod:: kill + .. automethod:: sendeof + .. automethod:: wait + + .. method:: expect + expect_exact + expect_list + + As :class:`pexpect.spawn`. http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/doc/api/pxssh.rst ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/doc/api/pxssh.rst b/tools/bin/pythonSrc/pexpect-4.2/doc/api/pxssh.rst new file mode 100644 index 0000000..b947f4b --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/doc/api/pxssh.rst @@ -0,0 +1,34 @@ +pxssh - control an SSH session +============================== + +.. automodule:: pexpect.pxssh + +.. autoclass:: ExceptionPxssh + +pxssh class +----------- + +.. autoclass:: pxssh + + .. automethod:: __init__ + + .. attribute:: PROMPT + + The regex pattern to search for to find the prompt. If you call :meth:`login` + with ``auto_prompt_reset=False``, you must set this attribute manually. + + .. attribute:: force_password + + If this is set to True, public key authentication is disabled, forcing the + server to ask for a password. Note that the sysadmin can disable password + logins, in which case this won't work. + + .. attribute:: options + + The dictionary of user specified SSH options, eg, ``options = dict(StrictHostKeyChecking="no", UserKnownHostsFile="/dev/null")`` + + .. automethod:: login + .. automethod:: logout + .. automethod:: prompt + .. automethod:: sync_original_prompt + .. automethod:: set_unique_prompt http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/doc/api/replwrap.rst ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/doc/api/replwrap.rst b/tools/bin/pythonSrc/pexpect-4.2/doc/api/replwrap.rst new file mode 100644 index 0000000..bf44a94 --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/doc/api/replwrap.rst @@ -0,0 +1,26 @@ +replwrap - Control read-eval-print-loops +======================================== + +.. automodule:: pexpect.replwrap + +.. versionadded:: 3.3 + +.. autoclass:: REPLWrapper + + .. automethod:: run_command + +.. data:: PEXPECT_PROMPT + + A string that can be used as a prompt, and is unlikely to be found in output. + +Using the objects above, it is easy to wrap a REPL. For instance, to use a +Python shell:: + + py = REPLWrapper("python", ">>> ", "import sys; sys.ps1={!r}; sys.ps2={!r}") + py.run_command("4+7") + +Convenience functions are provided for Python and bash shells: + +.. autofunction:: python + +.. autofunction:: bash http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/doc/clean.css ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/doc/clean.css b/tools/bin/pythonSrc/pexpect-4.2/doc/clean.css new file mode 100644 index 0000000..e8d98dd --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/doc/clean.css @@ -0,0 +1,103 @@ + +body { + margin:0px; + padding:0px; + font-family:verdana, arial, helvetica, sans-serif; + color:#333; + background-color:white; + } +pre { + background: #eeeeee; + border: 1px solid #888888; + color: black; + padding: 1em; + white-space: pre; +} +h1 { + margin:5px 0px 5px 0px; + padding:0px; + font-size:20px; + line-height:28px; + font-weight:900; + color:#44f; + } +h2 { + margin:5px 0px 5px 0px; + padding:0px; + font-size:17px; + line-height:28px; + font-weight:900; + color:#226; + } +h3 { + margin:5px 0px 5px 0px; + padding:0px; + font-size:15px; + line-height:28px; + font-weight:900; + } +p +{ + margin:0px 0px 16px 0px; + font:11px/20px verdana, arial, helvetica, sans-serif; + padding:0px; +} +table +{ + font-size: 10pt; + color: #000000; +} +td{border:1px solid #999;} + +table.pymenu {color: #000000; background-color: #99ccff} +th.pymenu {color: #ffffff; background-color: #003366} + +.code +{ + font-family: "Lucida Console", monospace; font-weight: bold; + color: #007700; background-color: #eeeeee +} + +#Content>p {margin:0px;} +#Content>p+p {text-indent:30px;} + +a { + text-decoration:none; + font-weight:600; + font-family:verdana, arial, helvetica, sans-serif; + color: #900; +} +//a:link {color:#09c;} +//a x:visited {color:#07a;} +a:hover {background-color:#ee0;} + +#Header { + margin:10px 0px 10px 0px; + padding:10px 0px 10px 20px; + /* For IE5/Win's benefit height = [correct height] + [top padding] + [top and bottom border widths] */ + height:33px; /* 14px + 17px + 2px = 33px */ + border-style:solid; + border-color:black; + border-width:1px 0px; /* top and bottom borders: 1px; left and right borders: 0px */ + line-height:33px; + background-color:#eee; + height:66px; /* the correct height */ + } + +#Content { + margin:0px 210px 50px 10px; + padding:10px; + } + +#Menu { + position:absolute; + top:100px; + right:20px; + width:172px; + padding:10px; + background-color:#eee; + border:1px solid #999; // dashed #999; + line-height:17px; + width:150px; + font-size:11px; + } http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/doc/commonissues.rst ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/doc/commonissues.rst b/tools/bin/pythonSrc/pexpect-4.2/doc/commonissues.rst new file mode 100644 index 0000000..f60085e --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/doc/commonissues.rst @@ -0,0 +1,101 @@ +Common problems +=============== + +Threads +------- + +On Linux (RH 8) you cannot spawn a child from a different thread and pass the +handle back to a worker thread. The child is successfully spawned but you can't +interact with it. The only way to make it work is to spawn and interact with the +child all in the same thread. [Adam Kerrison] + +Timing issue with send() and sendline() +--------------------------------------- + +This problem has been addressed and should not affect most users. + +It is sometimes possible to read an echo of the string sent with +:meth:`~pexpect.spawn.send` and :meth:`~pexpect.spawn.sendline`. If you call +:meth:`~pexpect.spawn.send` and then immediately call :meth:`~pexpect.spawn.readline`, +you may get part of your output echoed back. You may read back what you just +wrote even if the child application does not explicitly echo it. Timing is +critical. This could be a security issue when talking to an application that +asks for a password; otherwise, this does not seem like a big deal. But why do +TTYs do this? + +People usually report this when they are trying to control SSH or some other +login. For example, if your code looks something like this:: + + child.expect ('[pP]assword:') + child.sendline (my_password) + + +1. SSH prints "password:" prompt to the user. +2. SSH turns off echo on the TTY device. +3. SSH waits for user to enter a password. + +When scripting with Pexpect what can happen is that Pexpect will respond to the +"password:" prompt before SSH has had time to turn off TTY echo. In other words, +Pexpect sends the password between steps 1. and 2., so the password gets echoed +back to the TTY. I would call this an SSH bug. + +Pexpect now automatically adds a short delay before sending data to a child +process. This more closely mimics what happens in the usual human-to-app +interaction. The delay can be tuned with the ``delaybeforesend`` attribute of the +spawn class. In general, this fixes the problem for everyone and so this should +not be an issue for most users. For some applications you might with to turn it +off:: + + child = pexpect.spawn ("ssh [email protected]") + child.delaybeforesend = None + +Truncated output just before child exits +---------------------------------------- + +So far I have seen this only on older versions of Apple's MacOS X. If the child +application quits it may not flush its output buffer. This means that your +Pexpect application will receive an EOF even though it should have received a +little more data before the child died. This is not generally a problem when +talking to interactive child applications. One example where it is a problem is +when trying to read output from a program like *ls*. You may receive most of the +directory listing, but the last few lines will get lost before you receive an EOF. +The reason for this is that *ls* runs; completes its task; and then exits. The +buffer is not flushed before exit so the last few lines are lost. The following +example demonstrates the problem:: + + child = pexpect.spawn('ls -l') + child.expect(pexpect.EOF) + print child.before + +Controlling SSH on Solaris +-------------------------- + +Pexpect does not yet work perfectly on Solaris. One common problem is that SSH +sometimes will not allow TTY password authentication. For example, you may +expect SSH to ask you for a password using code like this:: + + child = pexpect.spawn('ssh [email protected]') + child.expect('password') + child.sendline('mypassword') + +You may see the following error come back from a spawned child SSH:: + + Permission denied (publickey,keyboard-interactive). + +This means that SSH thinks it can't access the TTY to ask you for your password. +The only solution I have found is to use public key authentication with SSH. +This bypasses the need for a password. I'm not happy with this solution. The +problem is due to poor support for Solaris Pseudo TTYs in the Python Standard +Library. + +child does not receive full input, emits BEL +-------------------------------------------- + +You may notice when running for example cat(1) or base64(1), when sending a +very long input line, that it is not fully received, and the BEL ('\a') may +be found in output. + +By default the child terminal matches the parent, which is often in "canonical +mode processing". You may wish to disable this mode. The exact limit of a line +varies by operating system, and details of disabling canonical mode may be +found in the docstring of :meth:`~pexpect.spawn.send`. http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/doc/conf.py ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/doc/conf.py b/tools/bin/pythonSrc/pexpect-4.2/doc/conf.py new file mode 100644 index 0000000..f3de534 --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/doc/conf.py @@ -0,0 +1,250 @@ +# -*- coding: utf-8 -*- +# +# Pexpect documentation build configuration file, created by +# sphinx-quickstart on Tue Sep 17 11:05:11 2013. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath('sphinxext')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', + 'sphinx.ext.viewcode', 'github', # for easy GitHub links + ] + +github_project_url = "https://github.com/pexpect/pexpect" + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'Pexpect' +copyright = u'2013, Noah Spurrier and contributors' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '4.2' +# The full version, including alpha/beta/rc tags. +release = '4.2.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# "<project> v<release> documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'Pexpectdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'Pexpect.tex', u'Pexpect Documentation', + u'Noah Spurrier and contributors', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'pexpect', u'Pexpect Documentation', + [u'Noah Spurrier and contributors'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'Pexpect', u'Pexpect Documentation', + u'Noah Spurrier and contributors', 'Pexpect', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'http://docs.python.org/3/': None} http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/doc/examples.rst ---------------------------------------------------------------------- diff --git a/tools/bin/pythonSrc/pexpect-4.2/doc/examples.rst b/tools/bin/pythonSrc/pexpect-4.2/doc/examples.rst new file mode 100644 index 0000000..6338b5c --- /dev/null +++ b/tools/bin/pythonSrc/pexpect-4.2/doc/examples.rst @@ -0,0 +1,63 @@ +Examples +======== + +Under the distribution tarball directory you should find an "examples" directory. +This is the best way to learn to use Pexpect. See the descriptions of Pexpect +Examples. + +`topip.py <https://github.com/pexpect/pexpect/blob/master/examples/topip.py>`_ + This runs `netstat` on a local or remote server. It calculates some simple + statistical information on the number of external inet connections. This can + be used to detect if one IP address is taking up an excessive number of + connections. It can also send an email alert if a given IP address exceeds a + threshold between runs of the script. This script can be used as a drop-in + Munin plugin or it can be used stand-alone from cron. I used this on a busy + web server that would sometimes get hit with denial of service attacks. This + made it easy to see if a script was opening many multiple connections. A + typical browser would open fewer than 10 connections at once. A script might + open over 100 simultaneous connections. + +`hive.py <https://github.com/pexpect/pexpect/blob/master/examples/hive.py>`_ + This script creates SSH connections to a list of hosts that you provide. + Then you are given a command line prompt. Each shell command that you + enter is sent to all the hosts. The response from each host is collected + and printed. For example, you could connect to a dozen different + machines and reboot them all at once. + +`script.py <https://github.com/pexpect/pexpect/blob/master/examples/script.py>`_ + This implements a command similar to the classic BSD "script" command. + This will start a subshell and log all input and output to a file. + This demonstrates the :meth:`~pexpect.spawn.interact` method of Pexpect. + +`ftp.py <https://github.com/pexpect/pexpect/blob/master/examples/ftp.py>`_ + This demonstrates an FTP "bookmark". This connects to an ftp site; + does a few ftp tasks; and then gives the user interactive control over + the session. In this case the "bookmark" is to a directory on the + OpenBSD ftp server. It puts you in the i386 packages directory. You + can easily modify this for other sites. This demonstrates the + :meth:`~pexpect.spawn.interact` method of Pexpect. + +`monitor.py <https://github.com/pexpect/pexpect/blob/master/examples/monitor.py>`_ + This runs a sequence of commands on a remote host using SSH. It runs a + simple system checks such as uptime and free to monitor the state of + the remote host. + +`passmass.py <https://github.com/pexpect/pexpect/blob/master/examples/passmass.py>`_ + This will login to each given server and change the password of the + given user. This demonstrates scripting logins and passwords. + +`python.py <https://github.com/pexpect/pexpect/blob/master/examples/python.py>`_ + This starts the python interpreter and prints the greeting message + backwards. It then gives the user iteractive control of Python. It's + pretty useless! + +`ssh_tunnel.py <https://github.com/pexpect/pexpect/blob/master/examples/ssh_tunnel.py>`_ + This starts an SSH tunnel to a remote machine. It monitors the + connection and restarts the tunnel if it goes down. + +`uptime.py <https://github.com/pexpect/pexpect/blob/master/examples/uptime.py>`_ + This will run the uptime command and parse the output into variables. + This demonstrates using a single regular expression to match the + output of a command and capturing different variable in match groups. + The grouping regular expression handles a wide variety of different + uptime formats.
