hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [06/11] incubator-hawq git commit: HAWQ-838. Replace python module paramiko with pexpect
Date Thu, 18 Aug 2016 02:44:31 GMT
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/pexpect/spawnbase.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/pexpect/spawnbase.py b/tools/bin/pythonSrc/pexpect-4.2/pexpect/spawnbase.py
new file mode 100644
index 0000000..5dd24b5
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/pexpect/spawnbase.py
@@ -0,0 +1,494 @@
+import codecs
+import os
+import sys
+import re
+import errno
+from .exceptions import ExceptionPexpect, EOF, TIMEOUT
+from .expect import Expecter, searcher_string, searcher_re
+
+PY3 = (sys.version_info[0] >= 3)
+text_type = str if PY3 else unicode
+
+class _NullCoder(object):
+    """Pass bytes through unchanged."""
+    @staticmethod
+    def encode(b, final=False):
+        return b
+
+    @staticmethod
+    def decode(b, final=False):
+        return b
+
+class SpawnBase(object):
+    """A base class providing the backwards-compatible spawn API for Pexpect.
+
+    This should not be instantiated directly: use :class:`pexpect.spawn` or
+    :class:`pexpect.fdpexpect.fdspawn`.
+    """
+    encoding = None
+    pid = None
+    flag_eof = False
+
+    def __init__(self, timeout=30, maxread=2000, searchwindowsize=None,
+                 logfile=None, encoding=None, codec_errors='strict'):
+        self.stdin = sys.stdin
+        self.stdout = sys.stdout
+        self.stderr = sys.stderr
+
+        self.searcher = None
+        self.ignorecase = False
+        self.before = None
+        self.after = None
+        self.match = None
+        self.match_index = None
+        self.terminated = True
+        self.exitstatus = None
+        self.signalstatus = None
+        # status returned by os.waitpid
+        self.status = None
+        # the child file descriptor is initially closed
+        self.child_fd = -1
+        self.timeout = timeout
+        self.delimiter = EOF
+        self.logfile = logfile
+        # input from child (read_nonblocking)
+        self.logfile_read = None
+        # output to send (send, sendline)
+        self.logfile_send = None
+        # max bytes to read at one time into buffer
+        self.maxread = maxread
+        # This is the read buffer. See maxread.
+        self.buffer = bytes() if (encoding is None) else text_type()
+        # Data before searchwindowsize point is preserved, but not searched.
+        self.searchwindowsize = searchwindowsize
+        # Delay used before sending data to child. Time in seconds.
+        # Set this to None to skip the time.sleep() call completely.
+        self.delaybeforesend = 0.05
+        # Used by close() to give kernel time to update process status.
+        # Time in seconds.
+        self.delayafterclose = 0.1
+        # Used by terminate() to give kernel time to update process status.
+        # Time in seconds.
+        self.delayafterterminate = 0.1
+        # Delay in seconds to sleep after each call to read_nonblocking().
+        # Set this to None to skip the time.sleep() call completely: that
+        # would restore the behavior from pexpect-2.0 (for performance
+        # reasons or because you don't want to release Python's global
+        # interpreter lock).
+        self.delayafterread = 0.0001
+        self.softspace = False
+        self.name = '<' + repr(self) + '>'
+        self.closed = True
+
+        # Unicode interface
+        self.encoding = encoding
+        self.codec_errors = codec_errors
+        if encoding is None:
+            # bytes mode (accepts some unicode for backwards compatibility)
+            self._encoder = self._decoder = _NullCoder()
+            self.string_type = bytes
+            self.crlf = b'\r\n'
+            if PY3:
+                self.allowed_string_types = (bytes, str)
+                self.linesep = os.linesep.encode('ascii')
+                def write_to_stdout(b):
+                    try:
+                        return sys.stdout.buffer.write(b)
+                    except AttributeError:
+                        # If stdout has been replaced, it may not have .buffer
+                        return sys.stdout.write(b.decode('ascii', 'replace'))
+                self.write_to_stdout = write_to_stdout
+            else:
+                self.allowed_string_types = (basestring,)  # analysis:ignore
+                self.linesep = os.linesep
+                self.write_to_stdout = sys.stdout.write
+        else:
+            # unicode mode
+            self._encoder = codecs.getincrementalencoder(encoding)(codec_errors)
+            self._decoder = codecs.getincrementaldecoder(encoding)(codec_errors)
+            self.string_type = text_type
+            self.crlf = u'\r\n'
+            self.allowed_string_types = (text_type, )
+            if PY3:
+                self.linesep = os.linesep
+            else:
+                self.linesep = os.linesep.decode('ascii')
+            # This can handle unicode in both Python 2 and 3
+            self.write_to_stdout = sys.stdout.write
+
+    def _log(self, s, direction):
+        if self.logfile is not None:
+            self.logfile.write(s)
+            self.logfile.flush()
+        second_log = self.logfile_send if (direction=='send') else self.logfile_read
+        if second_log is not None:
+            second_log.write(s)
+            second_log.flush()
+
+    # For backwards compatibility, in bytes mode (when encoding is None)
+    # unicode is accepted for send and expect. Unicode mode is strictly unicode
+    # only.
+    def _coerce_expect_string(self, s):
+        if self.encoding is None and not isinstance(s, bytes):
+            return s.encode('ascii')
+        return s
+
+    def _coerce_send_string(self, s):
+        if self.encoding is None and not isinstance(s, bytes):
+            return s.encode('utf-8')
+        return s
+
+    def read_nonblocking(self, size=1, timeout=None):
+        """This reads data from the file descriptor.
+
+        This is a simple implementation suitable for a regular file. Subclasses using ptys or pipes should override it.
+
+        The timeout parameter is ignored.
+        """
+
+        try:
+            s = os.read(self.child_fd, size)
+        except OSError as err:
+            if err.args[0] == errno.EIO:
+                # Linux-style EOF
+                self.flag_eof = True
+                raise EOF('End Of File (EOF). Exception style platform.')
+            raise
+        if s == b'':
+            # BSD-style EOF
+            self.flag_eof = True
+            raise EOF('End Of File (EOF). Empty string style platform.')
+
+        s = self._decoder.decode(s, final=False)
+        self._log(s, 'read')
+        return s
+
+    def _pattern_type_err(self, pattern):
+        raise TypeError('got {badtype} ({badobj!r}) as pattern, must be one'
+                        ' of: {goodtypes}, pexpect.EOF, pexpect.TIMEOUT'\
+                        .format(badtype=type(pattern),
+                                badobj=pattern,
+                                goodtypes=', '.join([str(ast)\
+                                    for ast in self.allowed_string_types])
+                                )
+                        )
+
+    def compile_pattern_list(self, patterns):
+        '''This compiles a pattern-string or a list of pattern-strings.
+        Patterns must be a StringType, EOF, TIMEOUT, SRE_Pattern, or a list of
+        those. Patterns may also be None which results in an empty list (you
+        might do this if waiting for an EOF or TIMEOUT condition without
+        expecting any pattern).
+
+        This is used by expect() when calling expect_list(). Thus expect() is
+        nothing more than::
+
+             cpl = self.compile_pattern_list(pl)
+             return self.expect_list(cpl, timeout)
+
+        If you are using expect() within a loop it may be more
+        efficient to compile the patterns first and then call expect_list().
+        This avoid calls in a loop to compile_pattern_list()::
+
+             cpl = self.compile_pattern_list(my_pattern)
+             while some_condition:
+                ...
+                i = self.expect_list(cpl, timeout)
+                ...
+        '''
+
+        if patterns is None:
+            return []
+        if not isinstance(patterns, list):
+            patterns = [patterns]
+
+        # Allow dot to match \n
+        compile_flags = re.DOTALL
+        if self.ignorecase:
+            compile_flags = compile_flags | re.IGNORECASE
+        compiled_pattern_list = []
+        for idx, p in enumerate(patterns):
+            if isinstance(p, self.allowed_string_types):
+                p = self._coerce_expect_string(p)
+                compiled_pattern_list.append(re.compile(p, compile_flags))
+            elif p is EOF:
+                compiled_pattern_list.append(EOF)
+            elif p is TIMEOUT:
+                compiled_pattern_list.append(TIMEOUT)
+            elif isinstance(p, type(re.compile(''))):
+                compiled_pattern_list.append(p)
+            else:
+                self._pattern_type_err(p)
+        return compiled_pattern_list
+
+    def expect(self, pattern, timeout=-1, searchwindowsize=-1, async=False):
+        '''This seeks through the stream until a pattern is matched. The
+        pattern is overloaded and may take several types. The pattern can be a
+        StringType, EOF, a compiled re, or a list of any of those types.
+        Strings will be compiled to re types. This returns the index into the
+        pattern list. If the pattern was not a list this returns index 0 on a
+        successful match. This may raise exceptions for EOF or TIMEOUT. To
+        avoid the EOF or TIMEOUT exceptions add EOF or TIMEOUT to the pattern
+        list. That will cause expect to match an EOF or TIMEOUT condition
+        instead of raising an exception.
+
+        If you pass a list of patterns and more than one matches, the first
+        match in the stream is chosen. If more than one pattern matches at that
+        point, the leftmost in the pattern list is chosen. For example::
+
+            # the input is 'foobar'
+            index = p.expect(['bar', 'foo', 'foobar'])
+            # returns 1('foo') even though 'foobar' is a "better" match
+
+        Please note, however, that buffering can affect this behavior, since
+        input arrives in unpredictable chunks. For example::
+
+            # the input is 'foobar'
+            index = p.expect(['foobar', 'foo'])
+            # returns 0('foobar') if all input is available at once,
+            # but returs 1('foo') if parts of the final 'bar' arrive late
+
+        When a match is found for the given pattern, the class instance
+        attribute *match* becomes an re.MatchObject result.  Should an EOF
+        or TIMEOUT pattern match, then the match attribute will be an instance
+        of that exception class.  The pairing before and after class
+        instance attributes are views of the data preceding and following
+        the matching pattern.  On general exception, class attribute
+        *before* is all data received up to the exception, while *match* and
+        *after* attributes are value None.
+
+        When the keyword argument timeout is -1 (default), then TIMEOUT will
+        raise after the default value specified by the class timeout
+        attribute. When None, TIMEOUT will not be raised and may block
+        indefinitely until match.
+
+        When the keyword argument searchwindowsize is -1 (default), then the
+        value specified by the class maxread attribute is used.
+
+        A list entry may be EOF or TIMEOUT instead of a string. This will
+        catch these exceptions and return the index of the list entry instead
+        of raising the exception. The attribute 'after' will be set to the
+        exception type. The attribute 'match' will be None. This allows you to
+        write code like this::
+
+                index = p.expect(['good', 'bad', pexpect.EOF, pexpect.TIMEOUT])
+                if index == 0:
+                    do_something()
+                elif index == 1:
+                    do_something_else()
+                elif index == 2:
+                    do_some_other_thing()
+                elif index == 3:
+                    do_something_completely_different()
+
+        instead of code like this::
+
+                try:
+                    index = p.expect(['good', 'bad'])
+                    if index == 0:
+                        do_something()
+                    elif index == 1:
+                        do_something_else()
+                except EOF:
+                    do_some_other_thing()
+                except TIMEOUT:
+                    do_something_completely_different()
+
+        These two forms are equivalent. It all depends on what you want. You
+        can also just expect the EOF if you are waiting for all output of a
+        child to finish. For example::
+
+                p = pexpect.spawn('/bin/ls')
+                p.expect(pexpect.EOF)
+                print p.before
+
+        If you are trying to optimize for speed then see expect_list().
+
+        On Python 3.4, or Python 3.3 with asyncio installed, passing
+        ``async=True``  will make this return an :mod:`asyncio` coroutine,
+        which you can yield from to get the same result that this method would
+        normally give directly. So, inside a coroutine, you can replace this code::
+
+            index = p.expect(patterns)
+
+        With this non-blocking form::
+
+            index = yield from p.expect(patterns, async=True)
+        '''
+
+        compiled_pattern_list = self.compile_pattern_list(pattern)
+        return self.expect_list(compiled_pattern_list,
+                timeout, searchwindowsize, async)
+
+    def expect_list(self, pattern_list, timeout=-1, searchwindowsize=-1,
+                    async=False):
+        '''This takes a list of compiled regular expressions and returns the
+        index into the pattern_list that matched the child output. The list may
+        also contain EOF or TIMEOUT(which are not compiled regular
+        expressions). This method is similar to the expect() method except that
+        expect_list() does not recompile the pattern list on every call. This
+        may help if you are trying to optimize for speed, otherwise just use
+        the expect() method.  This is called by expect().
+
+
+        Like :meth:`expect`, passing ``async=True`` will make this return an
+        asyncio coroutine.
+        '''
+        if timeout == -1:
+            timeout = self.timeout
+
+        exp = Expecter(self, searcher_re(pattern_list), searchwindowsize)
+        if async:
+            from .async import expect_async
+            return expect_async(exp, timeout)
+        else:
+            return exp.expect_loop(timeout)
+
+    def expect_exact(self, pattern_list, timeout=-1, searchwindowsize=-1,
+                     async=False):
+
+        '''This is similar to expect(), but uses plain string matching instead
+        of compiled regular expressions in 'pattern_list'. The 'pattern_list'
+        may be a string; a list or other sequence of strings; or TIMEOUT and
+        EOF.
+
+        This call might be faster than expect() for two reasons: string
+        searching is faster than RE matching and it is possible to limit the
+        search to just the end of the input buffer.
+
+        This method is also useful when you don't want to have to worry about
+        escaping regular expression characters that you want to match.
+
+        Like :meth:`expect`, passing ``async=True`` will make this return an
+        asyncio coroutine.
+        '''
+        if timeout == -1:
+            timeout = self.timeout
+
+        if (isinstance(pattern_list, self.allowed_string_types) or
+                pattern_list in (TIMEOUT, EOF)):
+            pattern_list = [pattern_list]
+
+        def prepare_pattern(pattern):
+            if pattern in (TIMEOUT, EOF):
+                return pattern
+            if isinstance(pattern, self.allowed_string_types):
+                return self._coerce_expect_string(pattern)
+            self._pattern_type_err(pattern)
+
+        try:
+            pattern_list = iter(pattern_list)
+        except TypeError:
+            self._pattern_type_err(pattern_list)
+        pattern_list = [prepare_pattern(p) for p in pattern_list]
+
+        exp = Expecter(self, searcher_string(pattern_list), searchwindowsize)
+        if async:
+            from .async import expect_async
+            return expect_async(exp, timeout)
+        else:
+            return exp.expect_loop(timeout)
+
+    def expect_loop(self, searcher, timeout=-1, searchwindowsize=-1):
+        '''This is the common loop used inside expect. The 'searcher' should be
+        an instance of searcher_re or searcher_string, which describes how and
+        what to search for in the input.
+
+        See expect() for other arguments, return value and exceptions. '''
+
+        exp = Expecter(self, searcher, searchwindowsize)
+        return exp.expect_loop(timeout)
+
+    def read(self, size=-1):
+        '''This reads at most "size" bytes from the file (less if the read hits
+        EOF before obtaining size bytes). If the size argument is negative or
+        omitted, read all data until EOF is reached. The bytes are returned as
+        a string object. An empty string is returned when EOF is encountered
+        immediately. '''
+
+        if size == 0:
+            return self.string_type()
+        if size < 0:
+            # delimiter default is EOF
+            self.expect(self.delimiter)
+            return self.before
+
+        # I could have done this more directly by not using expect(), but
+        # I deliberately decided to couple read() to expect() so that
+        # I would catch any bugs early and ensure consistant behavior.
+        # It's a little less efficient, but there is less for me to
+        # worry about if I have to later modify read() or expect().
+        # Note, it's OK if size==-1 in the regex. That just means it
+        # will never match anything in which case we stop only on EOF.
+        cre = re.compile(self._coerce_expect_string('.{%d}' % size), re.DOTALL)
+        # delimiter default is EOF
+        index = self.expect([cre, self.delimiter])
+        if index == 0:
+            ### FIXME self.before should be ''. Should I assert this?
+            return self.after
+        return self.before
+
+    def readline(self, size=-1):
+        '''This reads and returns one entire line. The newline at the end of
+        line is returned as part of the string, unless the file ends without a
+        newline. An empty string is returned if EOF is encountered immediately.
+        This looks for a newline as a CR/LF pair (\\r\\n) even on UNIX because
+        this is what the pseudotty device returns. So contrary to what you may
+        expect you will receive newlines as \\r\\n.
+
+        If the size argument is 0 then an empty string is returned. In all
+        other cases the size argument is ignored, which is not standard
+        behavior for a file-like object. '''
+
+        if size == 0:
+            return self.string_type()
+        # delimiter default is EOF
+        index = self.expect([self.crlf, self.delimiter])
+        if index == 0:
+            return self.before + self.crlf
+        else:
+            return self.before
+
+    def __iter__(self):
+        '''This is to support iterators over a file-like object.
+        '''
+        return iter(self.readline, self.string_type())
+
+    def readlines(self, sizehint=-1):
+        '''This reads until EOF using readline() and returns a list containing
+        the lines thus read. The optional 'sizehint' argument is ignored.
+        Remember, because this reads until EOF that means the child
+        process should have closed its stdout. If you run this method on
+        a child that is still running with its stdout open then this
+        method will block until it timesout.'''
+
+        lines = []
+        while True:
+            line = self.readline()
+            if not line:
+                break
+            lines.append(line)
+        return lines
+
+    def fileno(self):
+        '''Expose file descriptor for a file-like interface
+        '''
+        return self.child_fd
+
+    def flush(self):
+        '''This does nothing. It is here to support the interface for a
+        File-like object. '''
+        pass
+
+    def isatty(self):
+        """Overridden in subclass using tty"""
+        return False
+
+    # For 'with spawn(...) as child:'
+    def __enter__(self):
+        return self
+    
+    def __exit__(self, etype, evalue, tb):
+        # We rely on subclasses to implement close(). If they don't, it's not
+        # clear what a context manager should do.
+        self.close()

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/pexpect/utils.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/pexpect/utils.py b/tools/bin/pythonSrc/pexpect-4.2/pexpect/utils.py
new file mode 100644
index 0000000..ae0fe9d
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/pexpect/utils.py
@@ -0,0 +1,151 @@
+import os
+import sys
+import stat
+import select
+import time
+import errno
+
+try:
+    InterruptedError
+except NameError:
+    # Alias Python2 exception to Python3
+    InterruptedError = select.error
+
+
+def is_executable_file(path):
+    """Checks that path is an executable regular file, or a symlink towards one.
+
+    This is roughly ``os.path isfile(path) and os.access(path, os.X_OK)``.
+    """
+    # follow symlinks,
+    fpath = os.path.realpath(path)
+
+    if not os.path.isfile(fpath):
+        # non-files (directories, fifo, etc.)
+        return False
+
+    mode = os.stat(fpath).st_mode
+
+    if (sys.platform.startswith('sunos')
+            and os.getuid() == 0):
+        # When root on Solaris, os.X_OK is True for *all* files, irregardless
+        # of their executability -- instead, any permission bit of any user,
+        # group, or other is fine enough.
+        #
+        # (This may be true for other "Unix98" OS's such as HP-UX and AIX)
+        return bool(mode & (stat.S_IXUSR |
+                            stat.S_IXGRP |
+                            stat.S_IXOTH))
+
+    return os.access(fpath, os.X_OK)
+
+
+def which(filename, env=None):
+    '''This takes a given filename; tries to find it in the environment path;
+    then checks if it is executable. This returns the full path to the filename
+    if found and executable. Otherwise this returns None.'''
+
+    # Special case where filename contains an explicit path.
+    if os.path.dirname(filename) != '' and is_executable_file(filename):
+        return filename
+    if env is None:
+        env = os.environ
+    p = env.get('PATH')
+    if not p:
+        p = os.defpath
+    pathlist = p.split(os.pathsep)
+    for path in pathlist:
+        ff = os.path.join(path, filename)
+        if is_executable_file(ff):
+            return ff
+    return None
+
+
+def split_command_line(command_line):
+
+    '''This splits a command line into a list of arguments. It splits arguments
+    on spaces, but handles embedded quotes, doublequotes, and escaped
+    characters. It's impossible to do this with a regular expression, so I
+    wrote a little state machine to parse the command line. '''
+
+    arg_list = []
+    arg = ''
+
+    # Constants to name the states we can be in.
+    state_basic = 0
+    state_esc = 1
+    state_singlequote = 2
+    state_doublequote = 3
+    # The state when consuming whitespace between commands.
+    state_whitespace = 4
+    state = state_basic
+
+    for c in command_line:
+        if state == state_basic or state == state_whitespace:
+            if c == '\\':
+                # Escape the next character
+                state = state_esc
+            elif c == r"'":
+                # Handle single quote
+                state = state_singlequote
+            elif c == r'"':
+                # Handle double quote
+                state = state_doublequote
+            elif c.isspace():
+                # Add arg to arg_list if we aren't in the middle of whitespace.
+                if state == state_whitespace:
+                    # Do nothing.
+                    None
+                else:
+                    arg_list.append(arg)
+                    arg = ''
+                    state = state_whitespace
+            else:
+                arg = arg + c
+                state = state_basic
+        elif state == state_esc:
+            arg = arg + c
+            state = state_basic
+        elif state == state_singlequote:
+            if c == r"'":
+                state = state_basic
+            else:
+                arg = arg + c
+        elif state == state_doublequote:
+            if c == r'"':
+                state = state_basic
+            else:
+                arg = arg + c
+
+    if arg != '':
+        arg_list.append(arg)
+    return arg_list
+
+
+def select_ignore_interrupts(iwtd, owtd, ewtd, timeout=None):
+
+    '''This is a wrapper around select.select() that ignores signals. If
+    select.select raises a select.error exception and errno is an EINTR
+    error then it is ignored. Mainly this is used to ignore sigwinch
+    (terminal resize). '''
+
+    # if select() is interrupted by a signal (errno==EINTR) then
+    # we loop back and enter the select() again.
+    if timeout is not None:
+        end_time = time.time() + timeout
+    while True:
+        try:
+            return select.select(iwtd, owtd, ewtd, timeout)
+        except InterruptedError:
+            err = sys.exc_info()[1]
+            if err.args[0] == errno.EINTR:
+                # if we loop back we have to subtract the
+                # amount of time we already waited.
+                if timeout is not None:
+                    timeout = end_time - time.time()
+                    if timeout < 0:
+                        return([], [], [])
+            else:
+                # something else caused the select.error, so
+                # this actually is an exception.
+                raise

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/requirements-testing.txt
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/requirements-testing.txt b/tools/bin/pythonSrc/pexpect-4.2/requirements-testing.txt
new file mode 100644
index 0000000..1894122
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/requirements-testing.txt
@@ -0,0 +1,5 @@
+pytest
+pytest-cov
+coverage
+coveralls
+pytest-capturelog

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/setup.cfg
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/setup.cfg b/tools/bin/pythonSrc/pexpect-4.2/setup.cfg
new file mode 100644
index 0000000..87fce02
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/setup.cfg
@@ -0,0 +1,5 @@
+[pytest]
+norecursedirs = .git
+
+[bdist_wheel]
+universal=1

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/setup.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/setup.py b/tools/bin/pythonSrc/pexpect-4.2/setup.py
new file mode 100644
index 0000000..801b3b8
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/setup.py
@@ -0,0 +1,71 @@
+# encoding: utf-8
+from distutils.core import setup
+import os
+import re
+import sys
+
+if any(a == 'bdist_wheel' for a in sys.argv):
+    from setuptools import setup
+
+with open(os.path.join(os.path.dirname(__file__), 'pexpect', '__init__.py'), 'r') as f:
+    for line in f:
+        version_match = re.search(r"__version__ = ['\"]([^'\"]*)['\"]", line)
+        if version_match:
+            version = version_match.group(1)
+            break
+    else:
+        raise Exception("couldn't find version number")
+
+long_description = """
+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.
+"""
+
+setup (name='pexpect',
+    version=version,
+    packages=['pexpect'],
+    package_data={'pexpect': ['bashrc.sh']},
+    description='Pexpect allows easy control of interactive console applications.',
+    long_description=long_description,
+    author='Noah Spurrier; Thomas Kluyver; Jeff Quast',
+    author_email='noah@noah.org; thomas@kluyver.me.uk; contact@jeffquast.com',
+    url='https://pexpect.readthedocs.io/',
+    license='ISC license',
+    platforms='UNIX',
+    classifiers = [
+        'Development Status :: 5 - Production/Stable',
+        'Environment :: Console',
+        'Intended Audience :: Developers',
+        'Intended Audience :: System Administrators',
+        'License :: OSI Approved :: ISC License (ISCL)',
+        'Operating System :: POSIX',
+        'Operating System :: MacOS :: MacOS X',
+        'Programming Language :: Python',
+        'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: 3',
+        'Topic :: Software Development',
+        'Topic :: Software Development :: Libraries :: Python Modules',
+        'Topic :: Software Development :: Quality Assurance',
+        'Topic :: Software Development :: Testing',
+        'Topic :: System',
+        'Topic :: System :: Archiving :: Packaging',
+        'Topic :: System :: Installation/Setup',
+        'Topic :: System :: Shells',
+        'Topic :: System :: Software Distribution',
+        'Topic :: Terminals',
+    ],
+    install_requires=['ptyprocess>=0.5'],
+)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/PexpectTestCase.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/PexpectTestCase.py b/tools/bin/pythonSrc/pexpect-4.2/tests/PexpectTestCase.py
new file mode 100644
index 0000000..307437e
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/PexpectTestCase.py
@@ -0,0 +1,108 @@
+
+'''
+PEXPECT LICENSE
+
+    This license is approved by the OSI and FSF as GPL-compatible.
+        http://opensource.org/licenses/isc-license.txt
+
+    Copyright (c) 2012, Noah Spurrier <noah@noah.org>
+    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.
+
+'''
+from __future__ import print_function
+
+import contextlib
+import unittest
+import signal
+import sys
+import os
+
+
+class PexpectTestCase(unittest.TestCase):
+    def setUp(self):
+        self.PYTHONBIN = sys.executable
+        self.original_path = os.getcwd()
+        tests_dir = os.path.dirname(__file__)
+        self.project_dir = project_dir = os.path.dirname(tests_dir)
+
+        # all tests are executed in this folder; there are many auxiliary
+        # programs in this folder executed by spawn().
+        os.chdir(tests_dir)
+
+        # If the pexpect raises an exception after fork(), but before
+        # exec(), our test runner *also* forks.  We prevent this by
+        # storing our pid and asserting equality on tearDown.
+        self.pid = os.getpid()
+
+        coverage_rc = os.path.join(project_dir, '.coveragerc')
+        os.environ['COVERAGE_PROCESS_START'] = coverage_rc
+        os.environ['COVERAGE_FILE'] = os.path.join(project_dir, '.coverage')
+        print('\n', self.id(), end=' ')
+        sys.stdout.flush()
+
+        # some build agents will ignore SIGHUP and SIGINT, which python
+        # inherits.  This causes some of the tests related to terminate()
+        # to fail.  We set them to the default handlers that they should
+        # be, and restore them back to their SIG_IGN value on tearDown.
+        #
+        # I'm not entirely convinced they need to be restored, only our
+        # test runner is affected.
+        self.restore_ignored_signals = [
+            value for value in (signal.SIGHUP, signal.SIGINT,)
+            if signal.getsignal(value) == signal.SIG_IGN]
+        if signal.SIGHUP in self.restore_ignored_signals:
+            # sighup should be set to default handler
+            signal.signal(signal.SIGHUP, signal.SIG_DFL)
+        if signal.SIGINT in self.restore_ignored_signals:
+            # SIGINT should be set to signal.default_int_handler
+            signal.signal(signal.SIGINT, signal.default_int_handler)
+        unittest.TestCase.setUp(self)
+
+    def tearDown(self):
+        # restore original working folder
+        os.chdir(self.original_path)
+
+        if self.pid != os.getpid():
+            # The build server pattern-matches phrase 'Test runner has forked!'
+            print("Test runner has forked! This means a child process raised "
+                  "an exception before exec() in a test case, the error is "
+                  "more than likely found above this line in stderr.",
+                  file=sys.stderr)
+            exit(1)
+
+        # restore signal handlers
+        for signal_value in self.restore_ignored_signals:
+            signal.signal(signal_value, signal.SIG_IGN)
+
+    if sys.version_info < (2, 7):
+        # We want to use these methods, which are new/improved in 2.7, but
+        # we are still supporting 2.6 for the moment. This section can be
+        # removed when we drop Python 2.6 support.
+        @contextlib.contextmanager
+        def assertRaises(self, excClass):
+            try:
+                yield
+            except Exception as e:
+                assert isinstance(e, excClass)
+            else:
+                raise AssertionError("%s was not raised" % excClass)
+
+        @contextlib.contextmanager
+        def assertRaisesRegexp(self, excClass, pattern):
+            import re
+            try:
+                yield
+            except Exception as e:
+                assert isinstance(e, excClass)
+                assert re.match(pattern, str(e))
+            else:
+                raise AssertionError("%s was not raised" % excClass)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/README
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/README b/tools/bin/pythonSrc/pexpect-4.2/tests/README
new file mode 100644
index 0000000..ef5b613
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/README
@@ -0,0 +1,8 @@
+
+The best way to run these tests is from the directory above this one. Run:
+
+    py.test
+
+To run a specific test file:
+
+    py.test tests/test_constructor.py

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/TESTDATA.txt
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/TESTDATA.txt b/tools/bin/pythonSrc/pexpect-4.2/tests/TESTDATA.txt
new file mode 100644
index 0000000..adb9c01
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/TESTDATA.txt
@@ -0,0 +1,8 @@
+This is test data.
+    One
+    2
+    THREE
+    IV
+    .....
+    110
+This is the end of test data: END

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/__init__.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/__init__.py b/tools/bin/pythonSrc/pexpect-4.2/tests/__init__.py
new file mode 100755
index 0000000..f717d82
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/__init__.py
@@ -0,0 +1,25 @@
+
+'''
+PEXPECT LICENSE
+
+    This license is approved by the OSI and FSF as GPL-compatible.
+        http://opensource.org/licenses/isc-license.txt
+
+    Copyright (c) 2012, Noah Spurrier <noah@noah.org>
+    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.
+
+'''
+
+# __init__.py
+# The mere presence of this file makes the dir a package.
+pass
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/adhoc.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/adhoc.py b/tools/bin/pythonSrc/pexpect-4.2/tests/adhoc.py
new file mode 100755
index 0000000..0813d34
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/adhoc.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+'''
+PEXPECT LICENSE
+
+    This license is approved by the OSI and FSF as GPL-compatible.
+        http://opensource.org/licenses/isc-license.txt
+
+    Copyright (c) 2012, Noah Spurrier <noah@noah.org>
+    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.
+
+'''
+from  __future__ import print_function
+
+import pexpect
+import time
+
+p = pexpect.spawn ('./a.out')
+print(p.exitstatus)
+p.expect (pexpect.EOF)
+print(p.before)
+time.sleep(1)
+print('exitstatus:', p.exitstatus)
+print('isalive',p.isalive())
+print('exitstatus',p.exitstatus)
+print('isalive',p.isalive())
+print('exitstatus',p.exitstatus)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/alarm_die.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/alarm_die.py b/tools/bin/pythonSrc/pexpect-4.2/tests/alarm_die.py
new file mode 100644
index 0000000..a1519ab
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/alarm_die.py
@@ -0,0 +1,5 @@
+import signal, time
+
+signal.alarm(1) # Schedule SIGALRM in 1s
+
+time.sleep(6)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/bambi.vt
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/bambi.vt b/tools/bin/pythonSrc/pexpect-4.2/tests/bambi.vt
new file mode 100644
index 0000000..853f099
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/bambi.vt
@@ -0,0 +1,417 @@
+[?25l
+
+
+                         The
+                         The Adventures
+                         The Adventures of
+                         The Adventures of BAMBI
+                                                            
+                     Number
+                     Number One :
+                     Number One : BAMBI
+                     Number One : BAMBI versus
+                     Number One : BAMBI versus GODZILLA
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+                                                            
+
+ ,| *./\|(/|/
+   /| |/`|',/| \|/
+ \/_,| /| /, /<|\\/\|/|\
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /   .:::. .  /
+  \___________/
+    |\      |\
+    | >     | \
+   / /      |  \
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /   .:::. .  /
+  \___________/
+    \|      |\
+     \      | \
+    / \    /  |
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /   .:::. .  /
+  \___________/
+    \\      \|
+     \\      \ 
+     | \     |\
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /   .:::. .  /
+  \___________/
+    \\      \|
+     >\      \
+    / |     /|
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    |\      |\
+    | >     | \
+   / /      |  \
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    \|      |\
+     \      | \
+    / \    /  |
+          
+         
+--,_^_   
+.    .\  
+__--___o
+--_    
+.  \    
+__  \/|  
+|\(  .|
+| \\ /
+  | "
+--_    
+.  \    
+__  \/|  
+|\(  .|
+| \\ /
+  | "
+--_    
+.  \    
+__  \/|  
+|\(  .|
+| \\ /
+  | "
+--_    
+.  \    
+__  \/|  
+|\(  .|
+| \\ /
+  | "
+--,_^_  
+.    .\  
+__--___o
+|\        
+| \      
+  |      
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /     
+  \___________/     
+    \\      \|
+     \\      \ 
+     | \     |\
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    \\      \|
+     >\      \
+    / |     /|
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    |\      |\
+    | >     | \
+   / /      |  \
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    \|      |\
+     \      | \
+    / \    /  |
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    \\      \|
+     \\      \ 
+     | \     |\
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    \\      \|
+     >\      \
+    / |     /|
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    |\      |\
+    | >     | \
+   / /      |  \
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    \|      |\
+     \      | \
+    / \    /  |
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    \\      \|
+     \\      \ 
+     | \     |\
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    \\      \|
+     >\      \
+    / |     /|
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    |\      |\
+    | >     | \
+   / /      |  \
+        
+         
+--,_^_   
+.    .\  
+__--___o
+--_     
+.  \     
+__  \/|  
+|\(  .| 
+| \\ /
+|  \"
+--_      
+.  \     
+__  \/|   
+|\(  .|
+| \\ /
+|  \"
+--,_^_
+.    .\ 
+__--___o
+|\       
+| \      
+|  \     
+--,_^_
+.    .\ 
+__--___o
+|\       
+| \      
+|  \     
+--_      
+.  \     
+__  \/|   
+|\(  .|
+| \\ /
+|  \"
+--_      
+.  \     
+__  \/|   
+|\(  .|
+| \\ /
+|  \"
+--_      
+.  \     
+__  \/|   
+|\(  .|
+| \\ /
+|  \"
+--,_^_
+.    .\ 
+__--___o
+|\      
+| \     
+|  \    
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /    
+  \___________/     
+    \|      |\
+     \      | \
+    / \    /  |
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    \\      \|
+     \\      \ 
+     | \     |\
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    \\      \|
+     >\      \
+    / |     /|
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    |\      |\
+    | >     | \
+   / /      |  \
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    \|      |\
+     \      | \
+    / \    /  |
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    \\      \|
+     \\      \ 
+     | \     |\
+              _^_
+ o           /  .\
+  \,--------;   __o
+  /  .:::.. .  /
+  \___________/
+    \\      \|
+     >\      \
+    / |     /|
+                     
+ o                  
+  \,----------,_^_   
+  /  .:::.. .    .\  
+  \___________--___o
+    \\      \|
+     >\      \
+    / |     /|
+                     
+ o          
+  \,----------_    
+  /  .:::.. .  \    
+  \___________  \/|  
+    \\      \|(  .|
+     >\      \ \ /
+    / |     /|  "
+
+`'     `.__________________________________/M
+( /   (/M
+(-.___)M
+/     \/)M
+_______.--'\M
+,____________/\M
+(           /   )M
+(            )  /M
+\           \    )M
+(                 )M
+(    (            /M
+\    (             )M
+(     \             )M
+(    (              /M
+
+\    (        )      )M
+
+(     (        /      )M
+
+(     \         )     /M
+
+\    (          )      )M
+
+(                )      )M
+
+(                )      /M
+
+\                /       )M
+
+(                  )      )
+  /  >      | \
+                             
+                             
+          T          T          T
+          T H          T H          T H
+          T H E          T H E          T H E           T H E 
+          T H E   E          T H E   E          T H E   E
+          T H E   E N          T H E   E N          T H E   E N
+          T H E   E N D          T H E   E N D
+         ===============
+ 
+[?25h

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/depricated_test_filedescriptor.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/depricated_test_filedescriptor.py b/tools/bin/pythonSrc/pexpect-4.2/tests/depricated_test_filedescriptor.py
new file mode 100755
index 0000000..6b0ef3e
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/depricated_test_filedescriptor.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+'''
+PEXPECT LICENSE
+
+    This license is approved by the OSI and FSF as GPL-compatible.
+        http://opensource.org/licenses/isc-license.txt
+
+    Copyright (c) 2012, Noah Spurrier <noah@noah.org>
+    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.
+
+'''
+import pexpect
+import unittest
+import PexpectTestCase
+import os
+
+class ExpectTestCase(PexpectTestCase.PexpectTestCase):
+    def setUp(self):
+        print(self.id())
+        PexpectTestCase.PexpectTestCase.setUp(self)
+
+    def test_fd (self):
+        fd = os.open ('TESTDATA.txt', os.O_RDONLY)
+        s = pexpect.spawn (fd)
+        s.expect ('This is the end of test data:')
+        s.expect (pexpect.EOF)
+        assert s.before == ' END\n'
+
+    def test_maxread (self):
+        fd = os.open ('TESTDATA.txt', os.O_RDONLY)
+        s = pexpect.spawn (fd)
+        s.maxread = 100
+        s.expect('2')
+        s.expect ('This is the end of test data:')
+        s.expect (pexpect.EOF)
+        assert s.before == ' END\n'
+
+    def test_fd_isalive (self):
+        fd = os.open ('TESTDATA.txt', os.O_RDONLY)
+        s = pexpect.spawn (fd)
+        assert s.isalive()
+        os.close (fd)
+        assert not s.isalive()
+
+    def test_fd_isatty (self):
+        fd = os.open ('TESTDATA.txt', os.O_RDONLY)
+        s = pexpect.spawn (fd)
+        assert not s.isatty()
+        os.close(fd)
+
+###    def test_close_does_not_close_fd (self):
+###        '''Calling close() on a pexpect.spawn object should not
+###                close the underlying file descriptor.
+###        '''
+###        fd = os.open ('TESTDATA.txt', os.O_RDONLY)
+###        s = pexpect.spawn (fd)
+###        try:
+###            s.close()
+###            self.fail('Expected an Exception.')
+###        except pexpect.ExceptionPexpect, e:
+###            pass
+
+if __name__ == '__main__':
+    unittest.main()
+
+suite = unittest.makeSuite(ExpectTestCase, 'test')
+
+#fout = open('delete_me_1','wb')
+#fout.write(the_old_way)
+#fout.close
+#fout = open('delete_me_2', 'wb')
+#fout.write(the_new_way)
+#fout.close

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/echo_w_prompt.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/echo_w_prompt.py b/tools/bin/pythonSrc/pexpect-4.2/tests/echo_w_prompt.py
new file mode 100644
index 0000000..3c80553
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/echo_w_prompt.py
@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+from __future__ import print_function
+
+try:
+    raw_input
+except NameError:
+    raw_input = input
+
+while True:
+    try:
+        a = raw_input('<in >')
+    except EOFError:
+        print('<eof>')
+        break
+    print('<out>', a, sep='')

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/echo_wait.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/echo_wait.py b/tools/bin/pythonSrc/pexpect-4.2/tests/echo_wait.py
new file mode 100755
index 0000000..e152059
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/echo_wait.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+'''
+PEXPECT LICENSE
+
+    This license is approved by the OSI and FSF as GPL-compatible.
+        http://opensource.org/licenses/isc-license.txt
+
+    Copyright (c) 2012, Noah Spurrier <noah@noah.org>
+    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.
+
+'''
+import time
+import termios
+import sys
+
+# a dumb PAM will print the password prompt first then set ECHO
+# False. What it should do it set ECHO False first then print the
+# prompt. Otherwise, if we see the password prompt and type out
+# password real fast before it turns off ECHO then some or all of
+# our password might be visibly echod back to us. Sounds unlikely?
+# It happens.
+
+print("fake password:")
+sys.stdout.flush()
+time.sleep(3)
+attr = termios.tcgetattr(sys.stdout)
+attr[3] = attr[3] & ~termios.ECHO
+termios.tcsetattr(sys.stdout, termios.TCSANOW, attr)
+time.sleep(12)
+attr[3] = attr[3] | termios.ECHO
+termios.tcsetattr(sys.stdout, termios.TCSANOW, attr)
+time.sleep(2)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/exit1.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/exit1.py b/tools/bin/pythonSrc/pexpect-4.2/tests/exit1.py
new file mode 100755
index 0000000..587b8ad
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/exit1.py
@@ -0,0 +1,24 @@
+'''
+PEXPECT LICENSE
+
+    This license is approved by the OSI and FSF as GPL-compatible.
+        http://opensource.org/licenses/isc-license.txt
+
+    Copyright (c) 2012, Noah Spurrier <noah@noah.org>
+    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.
+
+'''
+import os, sys
+
+print("Hello")
+sys.stdout.flush()
+os._exit(1)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/exit667.c
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/exit667.c b/tools/bin/pythonSrc/pexpect-4.2/tests/exit667.c
new file mode 100644
index 0000000..962b9fd
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/exit667.c
@@ -0,0 +1,26 @@
+/*
+    PEXPECT LICENSE
+
+    This license is approved by the OSI and FSF as GPL-compatible.
+        http://opensource.org/licenses/isc-license.txt
+
+    Copyright (c) 2012, Noah Spurrier <noah@noah.org>
+    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.
+
+*/
+
+#include <stdio.h>
+int main ()
+{
+    printf ("Hello world!\n");
+    exit(7);
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/fakessh/ssh
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/fakessh/ssh b/tools/bin/pythonSrc/pexpect-4.2/tests/fakessh/ssh
new file mode 100755
index 0000000..28eedc4
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/fakessh/ssh
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+from __future__ import print_function
+
+import getpass
+import sys
+PY3 = (sys.version_info[0] >= 3)
+if not PY3:
+    input = raw_input
+
+print("Mock SSH client for tests. Do not enter real security info.")
+
+pw = getpass.getpass('password:')
+if pw != 's3cret':
+    print('Permission denied!')
+    sys.exit(1)
+
+prompt = "$"
+while True:
+    cmd = input(prompt)
+    if cmd.startswith('PS1='):
+        prompt = eval(cmd[4:]).replace('\$', '$')
+    elif cmd == 'ping':
+        print('pong')
+    elif cmd.startswith('ls'):
+        print('file1.py', 'file2.html', sep='\t')
+    elif cmd == 'echo $?':
+        print(0)
+    elif cmd in ('exit', 'logout'):
+        break
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a1a2f2c5/tools/bin/pythonSrc/pexpect-4.2/tests/getch.py
----------------------------------------------------------------------
diff --git a/tools/bin/pythonSrc/pexpect-4.2/tests/getch.py b/tools/bin/pythonSrc/pexpect-4.2/tests/getch.py
new file mode 100755
index 0000000..a362e52
--- /dev/null
+++ b/tools/bin/pythonSrc/pexpect-4.2/tests/getch.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+'''
+PEXPECT LICENSE
+
+    This license is approved by the OSI and FSF as GPL-compatible.
+        http://opensource.org/licenses/isc-license.txt
+
+    Copyright (c) 2012, Noah Spurrier <noah@noah.org>
+    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.
+
+'''
+from __future__ import print_function
+import sys, tty, termios
+
+if hasattr(sys.stdin, 'buffer'):
+    # Python 3: we want to read raw bytes
+    stdin = sys.stdin.buffer
+else:
+    stdin = sys.stdin
+
+def main():
+    print('READY', end='\r\n')
+    while True:
+        try:
+            val = ord(stdin.read(1))
+        except KeyboardInterrupt:
+            val = 3
+        print('%d<STOP>' % (val,), end='\r\n')
+        if val == 0:
+            # StopIteration equivalent is ctrl+' ' (\x00, NUL)
+            break
+
+if __name__ == '__main__':
+    fd = sys.stdin.fileno()
+    old_settings = termios.tcgetattr(fd)
+    try:
+        tty.setraw(sys.stdin.fileno())
+        main()
+    finally:
+        termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
+    sys.stdout.flush()


Mime
View raw message