aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pexpect
diff options
context:
space:
mode:
authorAlexSm <alex@ydb.tech>2023-12-27 23:31:58 +0100
committerGitHub <noreply@github.com>2023-12-27 23:31:58 +0100
commitd67bfb4b4b7549081543e87a31bc6cb5c46ac973 (patch)
tree8674f2f1570877cb653e7ddcff37ba00288de15a /contrib/python/pexpect
parent1f6bef05ed441c3aa2d565ac792b26cded704ac7 (diff)
downloadydb-d67bfb4b4b7549081543e87a31bc6cb5c46ac973.tar.gz
Import libs 4 (#758)
Diffstat (limited to 'contrib/python/pexpect')
-rw-r--r--contrib/python/pexpect/py2/.dist-info/METADATA11
-rw-r--r--contrib/python/pexpect/py2/pexpect/__init__.py10
-rw-r--r--contrib/python/pexpect/py2/pexpect/bashrc.sh2
-rw-r--r--contrib/python/pexpect/py2/pexpect/fdpexpect.py6
-rw-r--r--contrib/python/pexpect/py2/pexpect/popen_spawn.py2
-rw-r--r--contrib/python/pexpect/py2/pexpect/pxssh.py13
-rw-r--r--contrib/python/pexpect/py2/pexpect/replwrap.py22
-rw-r--r--contrib/python/pexpect/py2/pexpect/run.py2
-rw-r--r--contrib/python/pexpect/py2/pexpect/spawnbase.py13
-rw-r--r--contrib/python/pexpect/py2/ya.make2
10 files changed, 59 insertions, 24 deletions
diff --git a/contrib/python/pexpect/py2/.dist-info/METADATA b/contrib/python/pexpect/py2/.dist-info/METADATA
index 4c417227db..c5ea4a1a59 100644
--- a/contrib/python/pexpect/py2/.dist-info/METADATA
+++ b/contrib/python/pexpect/py2/.dist-info/METADATA
@@ -1,11 +1,15 @@
Metadata-Version: 2.1
Name: pexpect
-Version: 4.8.0
+Version: 4.9.0
Summary: Pexpect allows easy control of interactive console applications.
Home-page: https://pexpect.readthedocs.io/
Author: Noah Spurrier; Thomas Kluyver; Jeff Quast
Author-email: noah@noah.org, thomas@kluyver.me.uk, contact@jeffquast.com
License: ISC license
+Project-URL: Bug Tracker, https://github.com/pexpect/pexpect/issues
+Project-URL: Documentation, https://pexpect.readthedocs.io/
+Project-URL: Source Code, https://github.com/pexpect/pexpect
+Project-URL: History, https://pexpect.readthedocs.io/en/stable/history.html
Platform: UNIX
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
@@ -27,6 +31,7 @@ Classifier: Topic :: System :: Installation/Setup
Classifier: Topic :: System :: Shells
Classifier: Topic :: System :: Software Distribution
Classifier: Topic :: Terminals
+License-File: LICENSE
Requires-Dist: ptyprocess (>=0.5)
@@ -36,7 +41,7 @@ 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
+passwd, telnet, etc. It can be used to 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.
@@ -45,5 +50,3 @@ 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.
-
-
diff --git a/contrib/python/pexpect/py2/pexpect/__init__.py b/contrib/python/pexpect/py2/pexpect/__init__.py
index 7e30453787..86254ee720 100644
--- a/contrib/python/pexpect/py2/pexpect/__init__.py
+++ b/contrib/python/pexpect/py2/pexpect/__init__.py
@@ -1,6 +1,6 @@
'''Pexpect is a Python module for spawning child applications and controlling
them automatically. Pexpect can be used for automating interactive applications
-such as ssh, ftp, passwd, telnet, etc. It can be used to a automate setup
+such as ssh, ftp, passwd, telnet, etc. It can be used to 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. Other Expect-like modules for Python
@@ -29,6 +29,12 @@ For example::
child.expect('Password:')
child.sendline(mypassword)
+Context manager can be used for the spawn() function::
+
+ with pexpect.spawn('scp foo user@example.com:.') as child:
+ child.expect('Password:')
+ child.sendline(mypassword)
+
This works even for commands that ask for passwords or other input outside of
the normal stdio streams. For example, ssh reads input directly from the TTY
device which bypasses stdin.
@@ -75,7 +81,7 @@ if sys.platform != 'win32':
from .pty_spawn import spawn, spawnu
from .run import run, runu
-__version__ = '4.8.0'
+__version__ = '4.9.0'
__revision__ = ''
__all__ = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', 'spawnu', 'run', 'runu',
'which', 'split_command_line', '__version__', '__revision__']
diff --git a/contrib/python/pexpect/py2/pexpect/bashrc.sh b/contrib/python/pexpect/py2/pexpect/bashrc.sh
index c734ac90b8..d75d1a5b62 100644
--- a/contrib/python/pexpect/py2/pexpect/bashrc.sh
+++ b/contrib/python/pexpect/py2/pexpect/bashrc.sh
@@ -14,3 +14,5 @@ PS1="$"
# Unset PROMPT_COMMAND, so that it can't change PS1 to something unexpected.
unset PROMPT_COMMAND
+
+bind 'set enable-bracketed-paste off'
diff --git a/contrib/python/pexpect/py2/pexpect/fdpexpect.py b/contrib/python/pexpect/py2/pexpect/fdpexpect.py
index cddd50e100..140bdfeeda 100644
--- a/contrib/python/pexpect/py2/pexpect/fdpexpect.py
+++ b/contrib/python/pexpect/py2/pexpect/fdpexpect.py
@@ -1,7 +1,11 @@
-'''This is like pexpect, but it will work with any file descriptor that you
+'''This is like :mod:`pexpect`, but it will work with any file descriptor that you
pass it. You are responsible for opening and close the file descriptor.
This allows you to use Pexpect with sockets and named pipes (FIFOs).
+.. note::
+ socket.fileno() does not give a readable file descriptor on windows.
+ Use :mod:`pexpect.socket_pexpect` for cross-platform socket support
+
PEXPECT LICENSE
This license is approved by the OSI and FSF as GPL-compatible.
diff --git a/contrib/python/pexpect/py2/pexpect/popen_spawn.py b/contrib/python/pexpect/py2/pexpect/popen_spawn.py
index 4bb58cfe76..e6bdf07d61 100644
--- a/contrib/python/pexpect/py2/pexpect/popen_spawn.py
+++ b/contrib/python/pexpect/py2/pexpect/popen_spawn.py
@@ -57,7 +57,7 @@ class PopenSpawn(SpawnBase):
self._read_queue = Queue()
self._read_thread = threading.Thread(target=self._read_incoming)
- self._read_thread.setDaemon(True)
+ self._read_thread.daemon = True
self._read_thread.start()
_read_reached_eof = False
diff --git a/contrib/python/pexpect/py2/pexpect/pxssh.py b/contrib/python/pexpect/py2/pexpect/pxssh.py
index 3d53bd9746..742f59e406 100644
--- a/contrib/python/pexpect/py2/pexpect/pxssh.py
+++ b/contrib/python/pexpect/py2/pexpect/pxssh.py
@@ -143,8 +143,8 @@ class pxssh (spawn):
# used to set shell command-line prompt to UNIQUE_PROMPT.
self.PROMPT_SET_SH = r"PS1='[PEXPECT]\$ '"
self.PROMPT_SET_CSH = r"set prompt='[PEXPECT]\$ '"
- self.SSH_OPTS = ("-o'RSAAuthentication=no'"
- + " -o 'PubkeyAuthentication=no'")
+ self.PROMPT_SET_ZSH = "prompt restore;\nPS1='[PEXPECT]%(!.#.$) '"
+ self.SSH_OPTS = (" -o 'PubkeyAuthentication=no'")
# Disabling host key checking, makes you vulnerable to MITM attacks.
# + " -o 'StrictHostKeyChecking=no'"
# + " -o 'UserKnownHostsFile /dev/null' ")
@@ -152,7 +152,7 @@ class pxssh (spawn):
# displaying a GUI password dialog. I have not figured out how to
# disable only SSH_ASKPASS without also disabling X11 forwarding.
# Unsetting SSH_ASKPASS on the remote side doesn't disable it! Annoying!
- #self.SSH_OPTS = "-x -o'RSAAuthentication=no' -o 'PubkeyAuthentication=no'"
+ #self.SSH_OPTS = "-x -o 'PubkeyAuthentication=no'"
self.force_password = False
self.debug_command_string = debug_command_string
@@ -530,8 +530,11 @@ class pxssh (spawn):
if i == 0: # csh-style
self.sendline(self.PROMPT_SET_CSH)
i = self.expect([TIMEOUT, self.PROMPT], timeout=10)
- if i == 0:
- return False
+ if i == 0: # zsh-style
+ self.sendline(self.PROMPT_SET_ZSH)
+ i = self.expect([TIMEOUT, self.PROMPT], timeout=10)
+ if i == 0:
+ return False
return True
# vi:ts=4:sw=4:expandtab:ft=python:
diff --git a/contrib/python/pexpect/py2/pexpect/replwrap.py b/contrib/python/pexpect/py2/pexpect/replwrap.py
index c930f1e4fe..08dbd5e869 100644
--- a/contrib/python/pexpect/py2/pexpect/replwrap.py
+++ b/contrib/python/pexpect/py2/pexpect/replwrap.py
@@ -108,23 +108,29 @@ class REPLWrapper(object):
+ command)
return u''.join(res + [self.child.before])
-def python(command="python"):
+def python(command=sys.executable):
"""Start a Python shell and return a :class:`REPLWrapper` object."""
return REPLWrapper(command, u">>> ", u"import sys; sys.ps1={0!r}; sys.ps2={1!r}")
-def bash(command="bash"):
- """Start a bash shell and return a :class:`REPLWrapper` object."""
- bashrc = os.path.join(os.path.dirname(__file__), 'bashrc.sh')
- child = pexpect.spawn(command, ['--rcfile', bashrc], echo=False,
- encoding='utf-8')
+def _repl_sh(command, args, non_printable_insert):
+ child = pexpect.spawn(command, args, echo=False, encoding='utf-8')
# If the user runs 'env', the value of PS1 will be in the output. To avoid
# replwrap seeing that as the next prompt, we'll embed the marker characters
# for invisible characters in the prompt; these show up when inspecting the
# environment variable, but not when bash displays the prompt.
- ps1 = PEXPECT_PROMPT[:5] + u'\\[\\]' + PEXPECT_PROMPT[5:]
- ps2 = PEXPECT_CONTINUATION_PROMPT[:5] + u'\\[\\]' + PEXPECT_CONTINUATION_PROMPT[5:]
+ ps1 = PEXPECT_PROMPT[:5] + non_printable_insert + PEXPECT_PROMPT[5:]
+ ps2 = PEXPECT_CONTINUATION_PROMPT[:5] + non_printable_insert + PEXPECT_CONTINUATION_PROMPT[5:]
prompt_change = u"PS1='{0}' PS2='{1}' PROMPT_COMMAND=''".format(ps1, ps2)
return REPLWrapper(child, u'\\$', prompt_change,
extra_init_cmd="export PAGER=cat")
+
+def bash(command="bash"):
+ """Start a bash shell and return a :class:`REPLWrapper` object."""
+ bashrc = os.path.join(os.path.dirname(__file__), 'bashrc.sh')
+ return _repl_sh(command, ['--rcfile', bashrc], non_printable_insert='\\[\\]')
+
+def zsh(command="zsh", args=("--no-rcs", "-V", "+Z")):
+ """Start a zsh shell and return a :class:`REPLWrapper` object."""
+ return _repl_sh(command, list(args), non_printable_insert='%(!..)')
diff --git a/contrib/python/pexpect/py2/pexpect/run.py b/contrib/python/pexpect/py2/pexpect/run.py
index ff288a1246..5695ab7f7b 100644
--- a/contrib/python/pexpect/py2/pexpect/run.py
+++ b/contrib/python/pexpect/py2/pexpect/run.py
@@ -66,7 +66,7 @@ def run(command, timeout=30, withexitstatus=False, events=None,
The 'events' argument should be either a dictionary or a tuple list that
contains patterns and responses. Whenever one of the patterns is seen
in the command output, run() will send the associated response string.
- So, run() in the above example can be also written as:
+ So, run() in the above example can be also written as::
run("mencoder dvd://1 -o video.avi -oac copy -ovc copy",
events=[(TIMEOUT,print_ticks)], timeout=5)
diff --git a/contrib/python/pexpect/py2/pexpect/spawnbase.py b/contrib/python/pexpect/py2/pexpect/spawnbase.py
index 59e905764c..abf8071ec1 100644
--- a/contrib/python/pexpect/py2/pexpect/spawnbase.py
+++ b/contrib/python/pexpect/py2/pexpect/spawnbase.py
@@ -141,6 +141,16 @@ class SpawnBase(object):
return s.encode('ascii')
return s
+ # In bytes mode, regex patterns should also be of bytes type
+ def _coerce_expect_re(self, r):
+ p = r.pattern
+ if self.encoding is None and not isinstance(p, bytes):
+ return re.compile(p.encode('utf-8'))
+ # And vice-versa
+ elif self.encoding is not None and isinstance(p, bytes):
+ return re.compile(p.decode('utf-8'))
+ return r
+
def _coerce_send_string(self, s):
if self.encoding is None and not isinstance(s, bytes):
return s.encode('utf-8')
@@ -153,7 +163,7 @@ class SpawnBase(object):
self._buffer = self.buffer_type()
self._buffer.write(value)
- # This property is provided for backwards compatability (self.buffer used
+ # This property is provided for backwards compatibility (self.buffer used
# to be a string/bytes object)
buffer = property(_get_buffer, _set_buffer)
@@ -235,6 +245,7 @@ class SpawnBase(object):
elif p is TIMEOUT:
compiled_pattern_list.append(TIMEOUT)
elif isinstance(p, type(re.compile(''))):
+ p = self._coerce_expect_re(p)
compiled_pattern_list.append(p)
else:
self._pattern_type_err(p)
diff --git a/contrib/python/pexpect/py2/ya.make b/contrib/python/pexpect/py2/ya.make
index 9dc28a63d0..2498af4417 100644
--- a/contrib/python/pexpect/py2/ya.make
+++ b/contrib/python/pexpect/py2/ya.make
@@ -2,7 +2,7 @@
PY2_LIBRARY()
-VERSION(4.8.0)
+VERSION(4.9.0)
LICENSE(ISC)