pax_global_header00006660000000000000000000000064137723730650014527gustar00rootroot0000000000000052 comment=ee54ae2ee6bdd1e9f040dac79d799ae5b178e8fe ptyprocess-0.7.0/000077500000000000000000000000001377237306500137465ustar00rootroot00000000000000ptyprocess-0.7.0/.github/000077500000000000000000000000001377237306500153065ustar00rootroot00000000000000ptyprocess-0.7.0/.github/workflows/000077500000000000000000000000001377237306500173435ustar00rootroot00000000000000ptyprocess-0.7.0/.github/workflows/test.yml000066400000000000000000000007651377237306500210550ustar00rootroot00000000000000name: Test on: [push, pull_request] jobs: test: runs-on: ubuntu-latest strategy: matrix: python-version: [ 3.5, 3.6, 3.7, 3.8, 3.9, 2.7 ] steps: - uses: actions/checkout@v2 - name: Setup Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | pip install pytest - name: Run tests run: pytest -v ptyprocess-0.7.0/.gitignore000066400000000000000000000000701377237306500157330ustar00rootroot00000000000000__pycache__ *.pyc /build/ /dist/ MANIFEST docs/_build/ ptyprocess-0.7.0/LICENSE000066400000000000000000000016111377237306500147520ustar00rootroot00000000000000Ptyprocess is under the ISC license, as code derived from Pexpect. http://opensource.org/licenses/ISC Copyright (c) 2013-2014, Pexpect development team Copyright (c) 2012, Noah Spurrier 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. ptyprocess-0.7.0/README.rst000066400000000000000000000010351377237306500154340ustar00rootroot00000000000000Launch a subprocess in a pseudo terminal (pty), and interact with both the process and its pty. Sometimes, piping stdin and stdout is not enough. There might be a password prompt that doesn't read from stdin, output that changes when it's going to a pipe rather than a terminal, or curses-style interfaces that rely on a terminal. If you need to automate these things, running the process in a pseudo terminal (pty) is the answer. Interface:: p = PtyProcessUnicode.spawn(['python']) p.read(20) p.write('6+6\n') p.read(20) ptyprocess-0.7.0/docs/000077500000000000000000000000001377237306500146765ustar00rootroot00000000000000ptyprocess-0.7.0/docs/Makefile000066400000000000000000000151721377237306500163440ustar00rootroot00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) endif # 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 ' where 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 " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @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 " xml to make Docutils-native XML files" @echo " pseudoxml to make pseudoxml-XML files for display purposes" @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/Ptyprocess.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Ptyprocess.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/Ptyprocess" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Ptyprocess" @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." latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @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." xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." ptyprocess-0.7.0/docs/api.rst000066400000000000000000000002151377237306500161770ustar00rootroot00000000000000Ptyprocess API ============== .. module:: ptyprocess .. autoclass:: PtyProcess .. automethod:: spawn .. autoclass:: PtyProcessUnicode ptyprocess-0.7.0/docs/conf.py000066400000000000000000000203301377237306500161730ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # Ptyprocess documentation build configuration file, created by # sphinx-quickstart on Mon Oct 13 11:03:02 2014. # # 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 import 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('..')) # -- 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', ] # 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'Ptyprocess' copyright = u'2014, Thomas Kluyver' # 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 = '0.7' # The full version, including alpha/beta/rc tags. release = version #+ '.2' # 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 = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # -- 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 # " v 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'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. #html_extra_path = [] # 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 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 = 'Ptyprocessdoc' # -- 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, or own class]). latex_documents = [ ('index', 'Ptyprocess.tex', u'Ptyprocess Documentation', u'Thomas Kluyver', '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', 'ptyprocess', u'Ptyprocess Documentation', [u'Thomas Kluyver'], 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', 'Ptyprocess', u'Ptyprocess Documentation', u'Thomas Kluyver', 'Ptyprocess', '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' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = {'http://docs.python.org/': None} ptyprocess-0.7.0/docs/images/000077500000000000000000000000001377237306500161435ustar00rootroot00000000000000ptyprocess-0.7.0/docs/images/pty_vs_popen.png000066400000000000000000001245171377237306500214100ustar00rootroot00000000000000PNG  IHDRSBsBIT|d pHYsttfxtEXtSoftwarewww.inkscape.org< IDATxwxTe3% #]JQ)*v"UUWWu]]{?Zֲ W* bAAD#@)3$D$sRu"3sr;<󞷘#""""" ;HMb\DDDD$$*EDDDDBb\DDDD$$*EDDDDBb\DDDD$$*EDDDDBb\DDDD$$*EDDDDBb\DDDD$$*EDDDDBb\DDDD$$*EDDDDBb\DDDD$$*EDDDDBb\DDDD$$*EDDDDBb\DDDD$$*EDDDDBb\DDDD$$*EDDDDBb\DDDD$$*EDDDDBb\DDDD$$*EDDDDBb\DDDD$$*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o@=:ж5SSɔo9`yMzxyEc=us5Bpm`h qR'ZUѽm  n,UsUMFfҙ:+?E<&۹@{̜ t&/HZp| ,"ˀy@+f|qی1Vl4cVNfǬf@@ X+(4DTTlj8$"h0""Msp_g%ޑh^O_"[`;U&&" ;i|;x浤P$"@SrT:jyyt5TAV#M*X+vB]FoJU](" .;Ӹ>yv"yy|(c*#o~cD$T uG98 (LJ x)xp3@o7q&p[9HFHU)fLeT1cI|La1cAȒqc1c|bɸ1c1>dc1X2n1cO,7c1'c1Kƍ1c%c1Ēqc1c|bɸ1c1>dc1X2n1cO,7c1'c1Kƍ1c%c1Ēqc1c|bɸ1c1>dc1X2n1cO,7c1'c1Kƍ1c%c1Ēqc1c|bɸ1c1>dc1X2n1cO,7c1'c1Kƍ1c%c1Ēqc1c|bɸ1c1>dc1X2n1cO,7c1'c1Kƍ1c%c1Ēqc1c|bɸ1c1>dc1X2n1cO,7c1'r{Dv`IENDB`ptyprocess-0.7.0/docs/images/pty_vs_popen.svg000066400000000000000000000737261377237306500214300ustar00rootroot00000000000000 image/svg+xml Child Parent stdin stdout stderr w r w r w r Popen pipes Child Parent stdin stdout stderr slave master Pseudoterminal(pty) ptyprocess-0.7.0/docs/index.rst000066400000000000000000000033111377237306500165350ustar00rootroot00000000000000Ptyprocess ========== .. include:: ../README.rst Contents: .. toctree:: :maxdepth: 2 api What is a pty? -------------- A pty is a kernel-level object which processes can write data to and read data from, a bit like a pipe. Unlike a pipe, data moves through a single pty in both directions. When you use a program in a shell pipeline, or with :class:`subprocess.Popen` in Python, up to three pipes are created for the process's standard streams (stdin, stdout and stderr). When you run a program using ptyprocess, all three of its standard streams are connected to a single pty: .. image:: images/pty_vs_popen.png A pty also does more than a pipe. It keeps track of the window size (rows and columns of characters) and notifies child processes (with a SIGWINCH signal) when it changes. In *cooked mode*, it does some processing of data sent from the parent process, so for instance the byte ``03`` (entered as Ctrl-C) will cause SIGINT to be sent to the child process. Many command line programs behave differently if they detect that stdin or stdout is connected to a terminal instead of a pipe (using `isatty() `_), because this normally means that they're being used interactively by a human user. They may format output differently (e.g. ``ls`` lists files in columns) or prompt the user to confirm actions. When you run these programs in ptyprocess, they will exhibit their 'interactive' behaviour, instead of the 'pipe' behaviour you'll see using ``Popen()``. .. seealso:: `The TTY demystified `_ Detailed article by Linus Akesson Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` ptyprocess-0.7.0/ptyprocess/000077500000000000000000000000001377237306500161615ustar00rootroot00000000000000ptyprocess-0.7.0/ptyprocess/__init__.py000066400000000000000000000002121377237306500202650ustar00rootroot00000000000000"""Run a subprocess in a pseudo terminal""" from .ptyprocess import PtyProcess, PtyProcessUnicode, PtyProcessError __version__ = '0.7.0' ptyprocess-0.7.0/ptyprocess/_fork_pty.py000066400000000000000000000044721377237306500205360ustar00rootroot00000000000000"""Substitute for the forkpty system call, to support Solaris. """ import os import errno from pty import (STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO, CHILD) from .util import PtyProcessError def fork_pty(): '''This implements a substitute for the forkpty system call. This should be more portable than the pty.fork() function. Specifically, this should work on Solaris. Modified 10.06.05 by Geoff Marshall: Implemented __fork_pty() method to resolve the issue with Python's pty.fork() not supporting Solaris, particularly ssh. Based on patch to posixmodule.c authored by Noah Spurrier:: http://mail.python.org/pipermail/python-dev/2003-May/035281.html ''' parent_fd, child_fd = os.openpty() if parent_fd < 0 or child_fd < 0: raise OSError("os.openpty() failed") pid = os.fork() if pid == CHILD: # Child. os.close(parent_fd) pty_make_controlling_tty(child_fd) os.dup2(child_fd, STDIN_FILENO) os.dup2(child_fd, STDOUT_FILENO) os.dup2(child_fd, STDERR_FILENO) else: # Parent. os.close(child_fd) return pid, parent_fd def pty_make_controlling_tty(tty_fd): '''This makes the pseudo-terminal the controlling tty. This should be more portable than the pty.fork() function. Specifically, this should work on Solaris. ''' child_name = os.ttyname(tty_fd) # Disconnect from controlling tty, if any. Raises OSError of ENXIO # if there was no controlling tty to begin with, such as when # executed by a cron(1) job. try: fd = os.open("/dev/tty", os.O_RDWR | os.O_NOCTTY) os.close(fd) except OSError as err: if err.errno != errno.ENXIO: raise os.setsid() # Verify we are disconnected from controlling tty by attempting to open # it again. We expect that OSError of ENXIO should always be raised. try: fd = os.open("/dev/tty", os.O_RDWR | os.O_NOCTTY) os.close(fd) raise PtyProcessError("OSError of errno.ENXIO should be raised.") except OSError as err: if err.errno != errno.ENXIO: raise # Verify we can open child pty. fd = os.open(child_name, os.O_RDWR) os.close(fd) # Verify we now have a controlling tty. fd = os.open("/dev/tty", os.O_WRONLY) os.close(fd) ptyprocess-0.7.0/ptyprocess/ptyprocess.py000066400000000000000000000757061377237306500207650ustar00rootroot00000000000000import codecs import errno import fcntl import io import os import pty import resource import signal import struct import sys import termios import time try: import builtins # Python 3 except ImportError: import __builtin__ as builtins # Python 2 # Constants from pty import (STDIN_FILENO, CHILD) from .util import which, PtyProcessError _platform = sys.platform.lower() # Solaris uses internal __fork_pty(). All others use pty.fork(). _is_solaris = ( _platform.startswith('solaris') or _platform.startswith('sunos')) if _is_solaris: use_native_pty_fork = False from . import _fork_pty else: use_native_pty_fork = True PY3 = sys.version_info[0] >= 3 if PY3: def _byte(i): return bytes([i]) else: def _byte(i): return chr(i) class FileNotFoundError(OSError): pass class TimeoutError(OSError): pass _EOF, _INTR = None, None def _make_eof_intr(): """Set constants _EOF and _INTR. This avoids doing potentially costly operations on module load. """ global _EOF, _INTR if (_EOF is not None) and (_INTR is not None): return # inherit EOF and INTR definitions from controlling process. try: from termios import VEOF, VINTR fd = None for name in 'stdin', 'stdout': stream = getattr(sys, '__%s__' % name, None) if stream is None or not hasattr(stream, 'fileno'): continue try: fd = stream.fileno() except ValueError: continue if fd is None: # no fd, raise ValueError to fallback on CEOF, CINTR raise ValueError("No stream has a fileno") intr = ord(termios.tcgetattr(fd)[6][VINTR]) eof = ord(termios.tcgetattr(fd)[6][VEOF]) except (ImportError, OSError, IOError, ValueError, termios.error): # unless the controlling process is also not a terminal, # such as cron(1), or when stdin and stdout are both closed. # Fall-back to using CEOF and CINTR. There try: from termios import CEOF, CINTR (intr, eof) = (CINTR, CEOF) except ImportError: # ^C, ^D (intr, eof) = (3, 4) _INTR = _byte(intr) _EOF = _byte(eof) # setecho and setwinsize are pulled out here because on some platforms, we need # to do this from the child before we exec() def _setecho(fd, state): errmsg = 'setecho() may not be called on this platform (it may still be possible to enable/disable echo when spawning the child process)' try: attr = termios.tcgetattr(fd) except termios.error as err: if err.args[0] == errno.EINVAL: raise IOError(err.args[0], '%s: %s.' % (err.args[1], errmsg)) raise if state: attr[3] = attr[3] | termios.ECHO else: attr[3] = attr[3] & ~termios.ECHO try: # I tried TCSADRAIN and TCSAFLUSH, but these were inconsistent and # blocked on some platforms. TCSADRAIN would probably be ideal. termios.tcsetattr(fd, termios.TCSANOW, attr) except IOError as err: if err.args[0] == errno.EINVAL: raise IOError(err.args[0], '%s: %s.' % (err.args[1], errmsg)) raise def _setwinsize(fd, rows, cols): # Some very old platforms have a bug that causes the value for # termios.TIOCSWINSZ to be truncated. There was a hack here to work # around this, but it caused problems with newer platforms so has been # removed. For details see https://github.com/pexpect/pexpect/issues/39 TIOCSWINSZ = getattr(termios, 'TIOCSWINSZ', -2146929561) # Note, assume ws_xpixel and ws_ypixel are zero. s = struct.pack('HHHH', rows, cols, 0, 0) fcntl.ioctl(fd, TIOCSWINSZ, s) class PtyProcess(object): '''This class represents a process running in a pseudoterminal. The main constructor is the :meth:`spawn` classmethod. ''' string_type = bytes if PY3: linesep = os.linesep.encode('ascii') crlf = '\r\n'.encode('ascii') @staticmethod 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')) else: linesep = os.linesep crlf = '\r\n' write_to_stdout = sys.stdout.write encoding = None argv = None env = None launch_dir = None def __init__(self, pid, fd): _make_eof_intr() # Ensure _EOF and _INTR are calculated self.pid = pid self.fd = fd readf = io.open(fd, 'rb', buffering=0) writef = io.open(fd, 'wb', buffering=0, closefd=False) self.fileobj = io.BufferedRWPair(readf, writef) self.terminated = False self.closed = False self.exitstatus = None self.signalstatus = None # status returned by os.waitpid self.status = None self.flag_eof = False # 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 @classmethod def spawn( cls, argv, cwd=None, env=None, echo=True, preexec_fn=None, dimensions=(24, 80), pass_fds=()): '''Start the given command in a child process in a pseudo terminal. This does all the fork/exec type of stuff for a pty, and returns an instance of PtyProcess. If preexec_fn is supplied, it will be called with no arguments in the child process before exec-ing the specified command. It may, for instance, set signal handlers to SIG_DFL or SIG_IGN. Dimensions of the psuedoterminal used for the subprocess can be specified as a tuple (rows, cols), or the default (24, 80) will be used. By default, all file descriptors except 0, 1 and 2 are closed. This behavior can be overridden with pass_fds, a list of file descriptors to keep open between the parent and the child. ''' # Note that it is difficult for this method to fail. # You cannot detect if the child process cannot start. # So the only way you can tell if the child process started # or not is to try to read from the file descriptor. If you get # EOF immediately then it means that the child is already dead. # That may not necessarily be bad because you may have spawned a child # that performs some task; creates no stdout output; and then dies. if not isinstance(argv, (list, tuple)): raise TypeError("Expected a list or tuple for argv, got %r" % argv) # Shallow copy of argv so we can modify it argv = argv[:] command = argv[0] command_with_path = which(command) if command_with_path is None: raise FileNotFoundError('The command was not found or was not ' + 'executable: %s.' % command) command = command_with_path argv[0] = command # [issue #119] To prevent the case where exec fails and the user is # stuck interacting with a python child process instead of whatever # was expected, we implement the solution from # http://stackoverflow.com/a/3703179 to pass the exception to the # parent process # [issue #119] 1. Before forking, open a pipe in the parent process. exec_err_pipe_read, exec_err_pipe_write = os.pipe() if use_native_pty_fork: pid, fd = pty.fork() else: # Use internal fork_pty, for Solaris pid, fd = _fork_pty.fork_pty() # Some platforms must call setwinsize() and setecho() from the # child process, and others from the master process. We do both, # allowing IOError for either. if pid == CHILD: # set window size try: _setwinsize(STDIN_FILENO, *dimensions) except IOError as err: if err.args[0] not in (errno.EINVAL, errno.ENOTTY): raise # disable echo if spawn argument echo was unset if not echo: try: _setecho(STDIN_FILENO, False) except (IOError, termios.error) as err: if err.args[0] not in (errno.EINVAL, errno.ENOTTY): raise # [issue #119] 3. The child closes the reading end and sets the # close-on-exec flag for the writing end. os.close(exec_err_pipe_read) fcntl.fcntl(exec_err_pipe_write, fcntl.F_SETFD, fcntl.FD_CLOEXEC) # Do not allow child to inherit open file descriptors from parent, # with the exception of the exec_err_pipe_write of the pipe # and pass_fds. # Impose ceiling on max_fd: AIX bugfix for users with unlimited # nofiles where resource.RLIMIT_NOFILE is 2^63-1 and os.closerange() # occasionally raises out of range error max_fd = min(1048576, resource.getrlimit(resource.RLIMIT_NOFILE)[0]) spass_fds = sorted(set(pass_fds) | {exec_err_pipe_write}) for pair in zip([2] + spass_fds, spass_fds + [max_fd]): os.closerange(pair[0]+1, pair[1]) if cwd is not None: os.chdir(cwd) if preexec_fn is not None: try: preexec_fn() except Exception as e: ename = type(e).__name__ tosend = '{}:0:{}'.format(ename, str(e)) if PY3: tosend = tosend.encode('utf-8') os.write(exec_err_pipe_write, tosend) os.close(exec_err_pipe_write) os._exit(1) try: if env is None: os.execv(command, argv) else: os.execvpe(command, argv, env) except OSError as err: # [issue #119] 5. If exec fails, the child writes the error # code back to the parent using the pipe, then exits. tosend = 'OSError:{}:{}'.format(err.errno, str(err)) if PY3: tosend = tosend.encode('utf-8') os.write(exec_err_pipe_write, tosend) os.close(exec_err_pipe_write) os._exit(os.EX_OSERR) # Parent inst = cls(pid, fd) # Set some informational attributes inst.argv = argv if env is not None: inst.env = env if cwd is not None: inst.launch_dir = cwd # [issue #119] 2. After forking, the parent closes the writing end # of the pipe and reads from the reading end. os.close(exec_err_pipe_write) exec_err_data = os.read(exec_err_pipe_read, 4096) os.close(exec_err_pipe_read) # [issue #119] 6. The parent reads eof (a zero-length read) if the # child successfully performed exec, since close-on-exec made # successful exec close the writing end of the pipe. Or, if exec # failed, the parent reads the error code and can proceed # accordingly. Either way, the parent blocks until the child calls # exec. if len(exec_err_data) != 0: try: errclass, errno_s, errmsg = exec_err_data.split(b':', 2) exctype = getattr(builtins, errclass.decode('ascii'), Exception) exception = exctype(errmsg.decode('utf-8', 'replace')) if exctype is OSError: exception.errno = int(errno_s) except: raise Exception('Subprocess failed, got bad error data: %r' % exec_err_data) else: raise exception try: inst.setwinsize(*dimensions) except IOError as err: if err.args[0] not in (errno.EINVAL, errno.ENOTTY, errno.ENXIO): raise return inst def __repr__(self): clsname = type(self).__name__ if self.argv is not None: args = [repr(self.argv)] if self.env is not None: args.append("env=%r" % self.env) if self.launch_dir is not None: args.append("cwd=%r" % self.launch_dir) return "{}.spawn({})".format(clsname, ", ".join(args)) else: return "{}(pid={}, fd={})".format(clsname, self.pid, self.fd) @staticmethod def _coerce_send_string(s): if not isinstance(s, bytes): return s.encode('utf-8') return s @staticmethod def _coerce_read_string(s): return s def __del__(self): '''This makes sure that no system resources are left open. Python only garbage collects Python objects. OS file descriptors are not Python objects, so they must be handled explicitly. If the child file descriptor was opened outside of this class (passed to the constructor) then this does not close it. ''' if not self.closed: # It is possible for __del__ methods to execute during the # teardown of the Python VM itself. Thus self.close() may # trigger an exception because os.close may be None. try: self.close() # which exception, shouldn't we catch explicitly .. ? except: pass def fileno(self): '''This returns the file descriptor of the pty for the child. ''' return self.fd def close(self, force=True): '''This closes the connection with the child application. Note that calling close() more than once is valid. This emulates standard Python behavior with files. Set force to True if you want to make sure that the child is terminated (SIGKILL is sent if the child ignores SIGHUP and SIGINT). ''' if not self.closed: self.flush() self.fileobj.close() # Closes the file descriptor # Give kernel time to update process status. time.sleep(self.delayafterclose) if self.isalive(): if not self.terminate(force): raise PtyProcessError('Could not terminate the child.') self.fd = -1 self.closed = True #self.pid = None def flush(self): '''This does nothing. It is here to support the interface for a File-like object. ''' pass def isatty(self): '''This returns True if the file descriptor is open and connected to a tty(-like) device, else False. On SVR4-style platforms implementing streams, such as SunOS and HP-UX, the child pty may not appear as a terminal device. This means methods such as setecho(), setwinsize(), getwinsize() may raise an IOError. ''' return os.isatty(self.fd) def waitnoecho(self, timeout=None): '''This waits until the terminal ECHO flag is set False. This returns True if the echo mode is off. This returns False if the ECHO flag was not set False before the timeout. This can be used to detect when the child is waiting for a password. Usually a child application will turn off echo mode when it is waiting for the user to enter a password. For example, instead of expecting the "password:" prompt you can wait for the child to set ECHO off:: p = pexpect.spawn('ssh user@example.com') p.waitnoecho() p.sendline(mypassword) If timeout==None then this method to block until ECHO flag is False. ''' if timeout is not None: end_time = time.time() + timeout while True: if not self.getecho(): return True if timeout < 0 and timeout is not None: return False if timeout is not None: timeout = end_time - time.time() time.sleep(0.1) def getecho(self): '''This returns the terminal echo mode. This returns True if echo is on or False if echo is off. Child applications that are expecting you to enter a password often set ECHO False. See waitnoecho(). Not supported on platforms where ``isatty()`` returns False. ''' try: attr = termios.tcgetattr(self.fd) except termios.error as err: errmsg = 'getecho() may not be called on this platform' if err.args[0] == errno.EINVAL: raise IOError(err.args[0], '%s: %s.' % (err.args[1], errmsg)) raise self.echo = bool(attr[3] & termios.ECHO) return self.echo def setecho(self, state): '''This sets the terminal echo mode on or off. Note that anything the child sent before the echo will be lost, so you should be sure that your input buffer is empty before you call setecho(). For example, the following will work as expected:: p = pexpect.spawn('cat') # Echo is on by default. p.sendline('1234') # We expect see this twice from the child... p.expect(['1234']) # ... once from the tty echo... p.expect(['1234']) # ... and again from cat itself. p.setecho(False) # Turn off tty echo p.sendline('abcd') # We will set this only once (echoed by cat). p.sendline('wxyz') # We will set this only once (echoed by cat) p.expect(['abcd']) p.expect(['wxyz']) The following WILL NOT WORK because the lines sent before the setecho will be lost:: p = pexpect.spawn('cat') p.sendline('1234') p.setecho(False) # Turn off tty echo p.sendline('abcd') # We will set this only once (echoed by cat). p.sendline('wxyz') # We will set this only once (echoed by cat) p.expect(['1234']) p.expect(['1234']) p.expect(['abcd']) p.expect(['wxyz']) Not supported on platforms where ``isatty()`` returns False. ''' _setecho(self.fd, state) self.echo = state def read(self, size=1024): """Read and return at most ``size`` bytes from the pty. Can block if there is nothing to read. Raises :exc:`EOFError` if the terminal was closed. Unlike Pexpect's ``read_nonblocking`` method, this doesn't try to deal with the vagaries of EOF on platforms that do strange things, like IRIX or older Solaris systems. It handles the errno=EIO pattern used on Linux, and the empty-string return used on BSD platforms and (seemingly) on recent Solaris. """ try: s = self.fileobj.read1(size) except (OSError, IOError) as err: if err.args[0] == errno.EIO: # Linux-style EOF self.flag_eof = True raise EOFError('End Of File (EOF). Exception style platform.') raise if s == b'': # BSD-style EOF (also appears to work on recent Solaris (OpenIndiana)) self.flag_eof = True raise EOFError('End Of File (EOF). Empty string style platform.') return s def readline(self): """Read one line from the pseudoterminal, and return it as unicode. Can block if there is nothing to read. Raises :exc:`EOFError` if the terminal was closed. """ try: s = self.fileobj.readline() except (OSError, IOError) as err: if err.args[0] == errno.EIO: # Linux-style EOF self.flag_eof = True raise EOFError('End Of File (EOF). Exception style platform.') raise if s == b'': # BSD-style EOF (also appears to work on recent Solaris (OpenIndiana)) self.flag_eof = True raise EOFError('End Of File (EOF). Empty string style platform.') return s def _writeb(self, b, flush=True): n = self.fileobj.write(b) if flush: self.fileobj.flush() return n def write(self, s, flush=True): """Write bytes to the pseudoterminal. Returns the number of bytes written. """ return self._writeb(s, flush=flush) def sendcontrol(self, char): '''Helper method that wraps send() with mnemonic access for sending control character to the child (such as Ctrl-C or Ctrl-D). For example, to send Ctrl-G (ASCII 7, bell, '\a'):: child.sendcontrol('g') See also, sendintr() and sendeof(). ''' char = char.lower() a = ord(char) if 97 <= a <= 122: a = a - ord('a') + 1 byte = _byte(a) return self._writeb(byte), byte d = {'@': 0, '`': 0, '[': 27, '{': 27, '\\': 28, '|': 28, ']': 29, '}': 29, '^': 30, '~': 30, '_': 31, '?': 127} if char not in d: return 0, b'' byte = _byte(d[char]) return self._writeb(byte), byte def sendeof(self): '''This sends an EOF to the child. This sends a character which causes the pending parent output buffer to be sent to the waiting child program without waiting for end-of-line. If it is the first character of the line, the read() in the user program returns 0, which signifies end-of-file. This means to work as expected a sendeof() has to be called at the beginning of a line. This method does not send a newline. It is the responsibility of the caller to ensure the eof is sent at the beginning of a line. ''' return self._writeb(_EOF), _EOF def sendintr(self): '''This sends a SIGINT to the child. It does not require the SIGINT to be the first character on a line. ''' return self._writeb(_INTR), _INTR def eof(self): '''This returns True if the EOF exception was ever raised. ''' return self.flag_eof def terminate(self, force=False): '''This forces a child process to terminate. It starts nicely with SIGHUP and SIGINT. If "force" is True then moves onto SIGKILL. This returns True if the child was terminated. This returns False if the child could not be terminated. ''' if not self.isalive(): return True try: self.kill(signal.SIGHUP) time.sleep(self.delayafterterminate) if not self.isalive(): return True self.kill(signal.SIGCONT) time.sleep(self.delayafterterminate) if not self.isalive(): return True self.kill(signal.SIGINT) time.sleep(self.delayafterterminate) if not self.isalive(): return True if force: self.kill(signal.SIGKILL) time.sleep(self.delayafterterminate) if not self.isalive(): return True else: return False return False except OSError: # I think there are kernel timing issues that sometimes cause # this to happen. I think isalive() reports True, but the # process is dead to the kernel. # Make one last attempt to see if the kernel is up to date. time.sleep(self.delayafterterminate) if not self.isalive(): return True else: return False def wait(self): '''This waits until the child exits. This is a blocking call. This will not read any data from the child, so this will block forever if the child has unread output and has terminated. In other words, the child may have printed output then called exit(), but, the child is technically still alive until its output is read by the parent. ''' if self.isalive(): pid, status = os.waitpid(self.pid, 0) else: return self.exitstatus self.exitstatus = os.WEXITSTATUS(status) if os.WIFEXITED(status): self.status = status self.exitstatus = os.WEXITSTATUS(status) self.signalstatus = None self.terminated = True elif os.WIFSIGNALED(status): self.status = status self.exitstatus = None self.signalstatus = os.WTERMSIG(status) self.terminated = True elif os.WIFSTOPPED(status): # pragma: no cover # You can't call wait() on a child process in the stopped state. raise PtyProcessError('Called wait() on a stopped child ' + 'process. This is not supported. Is some other ' + 'process attempting job control with our child pid?') return self.exitstatus def isalive(self): '''This tests if the child process is running or not. This is non-blocking. If the child was terminated then this will read the exitstatus or signalstatus of the child. This returns True if the child process appears to be running or False if not. It can take literally SECONDS for Solaris to return the right status. ''' if self.terminated: return False if self.flag_eof: # This is for Linux, which requires the blocking form # of waitpid to get the status of a defunct process. # This is super-lame. The flag_eof would have been set # in read_nonblocking(), so this should be safe. waitpid_options = 0 else: waitpid_options = os.WNOHANG try: pid, status = os.waitpid(self.pid, waitpid_options) except OSError as e: # No child processes if e.errno == errno.ECHILD: raise PtyProcessError('isalive() encountered condition ' + 'where "terminated" is 0, but there was no child ' + 'process. Did someone else call waitpid() ' + 'on our process?') else: raise # I have to do this twice for Solaris. # I can't even believe that I figured this out... # If waitpid() returns 0 it means that no child process # wishes to report, and the value of status is undefined. if pid == 0: try: ### os.WNOHANG) # Solaris! pid, status = os.waitpid(self.pid, waitpid_options) except OSError as e: # pragma: no cover # This should never happen... if e.errno == errno.ECHILD: raise PtyProcessError('isalive() encountered condition ' + 'that should never happen. There was no child ' + 'process. Did someone else call waitpid() ' + 'on our process?') else: raise # If pid is still 0 after two calls to waitpid() then the process # really is alive. This seems to work on all platforms, except for # Irix which seems to require a blocking call on waitpid or select, # so I let read_nonblocking take care of this situation # (unfortunately, this requires waiting through the timeout). if pid == 0: return True if pid == 0: return True if os.WIFEXITED(status): self.status = status self.exitstatus = os.WEXITSTATUS(status) self.signalstatus = None self.terminated = True elif os.WIFSIGNALED(status): self.status = status self.exitstatus = None self.signalstatus = os.WTERMSIG(status) self.terminated = True elif os.WIFSTOPPED(status): raise PtyProcessError('isalive() encountered condition ' + 'where child process is stopped. This is not ' + 'supported. Is some other process attempting ' + 'job control with our child pid?') return False def kill(self, sig): """Send the given signal to the child application. In keeping with UNIX tradition it has a misleading name. It does not necessarily kill the child unless you send the right signal. See the :mod:`signal` module for constants representing signal numbers. """ # Same as os.kill, but the pid is given for you. if self.isalive(): os.kill(self.pid, sig) def getwinsize(self): """Return the window size of the pseudoterminal as a tuple (rows, cols). """ TIOCGWINSZ = getattr(termios, 'TIOCGWINSZ', 1074295912) s = struct.pack('HHHH', 0, 0, 0, 0) x = fcntl.ioctl(self.fd, TIOCGWINSZ, s) return struct.unpack('HHHH', x)[0:2] def setwinsize(self, rows, cols): """Set the terminal window size of the child tty. This will cause a SIGWINCH signal to be sent to the child. This does not change the physical window size. It changes the size reported to TTY-aware applications like vi or curses -- applications that respond to the SIGWINCH signal. """ return _setwinsize(self.fd, rows, cols) class PtyProcessUnicode(PtyProcess): """Unicode wrapper around a process running in a pseudoterminal. This class exposes a similar interface to :class:`PtyProcess`, but its read methods return unicode, and its :meth:`write` accepts unicode. """ if PY3: string_type = str else: string_type = unicode # analysis:ignore def __init__(self, pid, fd, encoding='utf-8', codec_errors='strict'): super(PtyProcessUnicode, self).__init__(pid, fd) self.encoding = encoding self.codec_errors = codec_errors self.decoder = codecs.getincrementaldecoder(encoding)(errors=codec_errors) def read(self, size=1024): """Read at most ``size`` bytes from the pty, return them as unicode. Can block if there is nothing to read. Raises :exc:`EOFError` if the terminal was closed. The size argument still refers to bytes, not unicode code points. """ b = super(PtyProcessUnicode, self).read(size) return self.decoder.decode(b, final=False) def readline(self): """Read one line from the pseudoterminal, and return it as unicode. Can block if there is nothing to read. Raises :exc:`EOFError` if the terminal was closed. """ b = super(PtyProcessUnicode, self).readline() return self.decoder.decode(b, final=False) def write(self, s): """Write the unicode string ``s`` to the pseudoterminal. Returns the number of bytes written. """ b = s.encode(self.encoding) return super(PtyProcessUnicode, self).write(b) ptyprocess-0.7.0/ptyprocess/util.py000066400000000000000000000053411377237306500175130ustar00rootroot00000000000000try: from shutil import which # Python >= 3.3 except ImportError: import os, sys # This is copied from Python 3.4.1 def which(cmd, mode=os.F_OK | os.X_OK, path=None): """Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path. """ # Check that a given file can be accessed with the correct mode. # Additionally check that `file` is not a directory, as on Windows # directories pass the os.access check. def _access_check(fn, mode): return (os.path.exists(fn) and os.access(fn, mode) and not os.path.isdir(fn)) # If we're given a path with a directory part, look it up directly rather # than referring to PATH directories. This includes checking relative to the # current directory, e.g. ./script if os.path.dirname(cmd): if _access_check(cmd, mode): return cmd return None if path is None: path = os.environ.get("PATH", os.defpath) if not path: return None path = path.split(os.pathsep) if sys.platform == "win32": # The current directory takes precedence on Windows. if not os.curdir in path: path.insert(0, os.curdir) # PATHEXT is necessary to check on Windows. pathext = os.environ.get("PATHEXT", "").split(os.pathsep) # See if the given file matches any of the expected path extensions. # This will allow us to short circuit when given "python.exe". # If it does match, only test that one, otherwise we have to try # others. if any(cmd.lower().endswith(ext.lower()) for ext in pathext): files = [cmd] else: files = [cmd + ext for ext in pathext] else: # On other platforms you don't have things like PATHEXT to tell you # what file suffixes are executable, so just pass on cmd as-is. files = [cmd] seen = set() for dir in path: normdir = os.path.normcase(dir) if not normdir in seen: seen.add(normdir) for thefile in files: name = os.path.join(dir, thefile) if _access_check(name, mode): return name return None class PtyProcessError(Exception): """Generic error class for this package.""" ptyprocess-0.7.0/pyproject.toml000066400000000000000000000013521377237306500166630ustar00rootroot00000000000000[build-system] requires = ["flit_core >=2,<4"] build-backend = "flit_core.buildapi" [tool.flit.metadata] module = "ptyprocess" author = "Thomas Kluyver" author-email = "thomas@kluyver.me.uk" home-page = "https://github.com/pexpect/ptyprocess" description-file = "README.rst" 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 :: Terminals" ] ptyprocess-0.7.0/readthedocs.yml000066400000000000000000000000271377237306500167550ustar00rootroot00000000000000python: version: 3 ptyprocess-0.7.0/tests/000077500000000000000000000000001377237306500151105ustar00rootroot00000000000000ptyprocess-0.7.0/tests/__init__.py000066400000000000000000000000001377237306500172070ustar00rootroot00000000000000ptyprocess-0.7.0/tests/test_echo.py000066400000000000000000000024061377237306500174410ustar00rootroot00000000000000import time import unittest from ptyprocess.ptyprocess import _is_solaris from ptyprocess import PtyProcess class PtyEchoTestCase(unittest.TestCase): def _read_until_eof(self, proc): """Read away all output on ``proc`` until EOF.""" while True: try: proc.read() except EOFError: return @unittest.skipIf(_is_solaris, "waitnoecho cannot be called on this platform.") def test_waitnoecho_forever(self): """Ensure waitnoecho() with no timeout will return when echo=False.""" cat = PtyProcess.spawn(['cat'], echo=False) assert cat.waitnoecho() == True assert cat.echo == False assert cat.getecho() == False cat.sendeof() self._read_until_eof(cat) assert cat.wait() == 0 @unittest.skipIf(_is_solaris, "waitnoecho cannot be called on this platform.") def test_waitnoecho_timeout(self): """Ensure waitnoecho() with timeout will return when using stty to unset echo.""" cat = PtyProcess.spawn(['cat'], echo=True) assert cat.waitnoecho(timeout=1) == False assert cat.echo == True assert cat.getecho() == True cat.sendeof() self._read_until_eof(cat) assert cat.wait() == 0 ptyprocess-0.7.0/tests/test_invalid_binary.py000077500000000000000000000051221377237306500215160ustar00rootroot00000000000000#!/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 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 unittest from ptyprocess import PtyProcess, PtyProcessUnicode import errno import os import stat import tempfile class InvalidBinaryChars(unittest.TestCase): def test_invalid_binary(self): '''This tests that we correctly handle the case where we attempt to spawn a child process but the exec call fails''' # Create a file that should fail the exec call dirpath = tempfile.mkdtemp() fullpath = os.path.join(dirpath, "test") with open(fullpath, 'wb') as f: # Add some constant so it will never be executable # - Not 0x54AD (Windows PE) # - Not 0x7FEF (ELF) # - Not 0410 or 0413 (a.out) # - Not 0x2321 (script) file_start = b'\x00\x00' file_data = file_start + os.urandom(1022) f.write(file_data) # Make it executable st = os.stat(fullpath) os.chmod(fullpath, st.st_mode | stat.S_IEXEC) # TODO Verify this does what is intended on Windows try: child = PtyProcess.spawn([fullpath]) # If we get here then an OSError was not raised child.close() raise AssertionError("OSError was not raised") except OSError as err: if errno.ENOEXEC == err.errno: # This is what should happen pass else: # Re-raise the original error to fail the test raise finally: os.unlink(fullpath) os.rmdir(dirpath) if __name__ == '__main__': unittest.main() suite = unittest.makeSuite(InvalidBinaryChars,'test') ptyprocess-0.7.0/tests/test_preexec_fn.py000077500000000000000000000037441377237306500206520ustar00rootroot00000000000000#!/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 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 unittest import shutil from ptyprocess import PtyProcess import os import tempfile class PreexecFns(unittest.TestCase): def test_preexec(self): td = tempfile.mkdtemp() filepath = os.path.join(td, 'foo') def pef(): with open(filepath, 'w') as f: f.write('bar') try: child = PtyProcess.spawn(['ls'], preexec_fn=pef) child.close() with open(filepath, 'r') as f: assert f.read() == 'bar' finally: shutil.rmtree(td) def test_preexec_error(self): def func(): raise ValueError("Test error condition") try: child = PtyProcess.spawn(['ls'], preexec_fn=func) # If we get here then an error was not raised child.close() raise AssertionError("ValueError was not raised") except ValueError as err: if str(err) != "Test error condition": # Re-raise the original error to fail the test raise ptyprocess-0.7.0/tests/test_spawn.py000077500000000000000000000114131377237306500176540ustar00rootroot00000000000000import fcntl import os import time import select import tempfile import unittest from ptyprocess.ptyprocess import which from ptyprocess import PtyProcess, PtyProcessUnicode class PtyTestCase(unittest.TestCase): def setUp(self): self.cmd = u'echo $ENV_KEY; exit 0\n' self.env = os.environ.copy() self.env_key = u'ENV_KEY' self.env_value = u'env_value' self.env[self.env_key] = self.env_value def _canread(self, fd, timeout=1): return fd in select.select([fd], [], [], timeout)[0] def _spawn_sh(self, ptyp, cmd, outp, env_value): # given, p = ptyp.spawn(['sh'], env=self.env) p.write(cmd) # exercise, while True: try: outp += p.read() except EOFError: break # verify, input is echo to output assert cmd.strip() in outp # result of echo $ENV_KEY in output assert env_value in outp # exit successfully (exit 0) assert p.wait() == 0 def test_spawn_sh(self): outp = b'' self._spawn_sh(PtyProcess, self.cmd.encode('ascii'), outp, self.env_value.encode('ascii')) def test_spawn_sh_unicode(self): outp = u'' self._spawn_sh(PtyProcessUnicode, self.cmd, outp, self.env_value) def test_quick_spawn(self): """Spawn a very short-lived process.""" # so far only reproducible on Solaris 11, spawning a process # that exits very quickly raised an exception at 'inst.setwinsize', # because the pty file descriptor was quickly lost after exec(). PtyProcess.spawn(['true']) def _interactive_repl_unicode(self, echo): """Test Call and response with echo ON/OFF.""" # given, bc = PtyProcessUnicode.spawn(['bc'], echo=echo) given_input = u'2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2\n' expected_output = u'40' # gnu-bc will display a long FSF banner on startup, # whereas bsd-bc (on FreeBSD, Solaris) display no # banner at all. To ensure we've read up to our # current prompt, read until the response of '2^16' is found. time.sleep(1) bc.write(u'2^16\n') outp = u'' while self._canread(bc.fd): outp += bc.read() assert u'65536' in outp # exercise, bc.write(given_input) while self._canread(bc.fd, timeout=2): outp += bc.read() # with echo ON, we should see our input. # # note: we cannot assert the reverse: on Solaris, FreeBSD, # and OSX, our input is echoed to output even with echo=False, # something to do with the non-gnu version of bc(1), perhaps. if echo: assert given_input.strip() in outp # we should most certainly see the result output. assert expected_output in outp # exercise sending EOF bc.sendeof() # validate EOF on read while True: try: bc.read() except EOFError: break # validate exit status, assert bc.wait() == 0 @unittest.skipIf(which('bc') is None, "bc(1) not found on this server.") def test_interactive_repl_unicode_noecho(self): self._interactive_repl_unicode(echo=False) @unittest.skipIf(which('bc') is None, "bc(1) not found on this server.") def test_interactive_repl_unicode_echo(self): self._interactive_repl_unicode(echo=True) def test_pass_fds(self): with tempfile.NamedTemporaryFile() as temp_file: temp_file_fd = temp_file.fileno() temp_file_name = temp_file.name # Temporary files are CLOEXEC by default fcntl.fcntl(temp_file_fd, fcntl.F_SETFD, fcntl.fcntl(temp_file_fd, fcntl.F_GETFD) & ~fcntl.FD_CLOEXEC) # You can write with pass_fds p = PtyProcess.spawn(['bash', '-c', 'printf hello >&{}'.format(temp_file_fd)], echo=True, pass_fds=(temp_file_fd,)) p.wait() assert p.status == 0 with open(temp_file_name, 'r') as temp_file_r: assert temp_file_r.read() == 'hello' # You can't write without pass_fds p = PtyProcess.spawn(['bash', '-c', 'printf bye >&{}'.format(temp_file_fd)], echo=True) p.wait() assert p.status != 0 with open(temp_file_name, 'r') as temp_file_r: assert temp_file_r.read() == 'hello' ptyprocess-0.7.0/tests/test_wait.py000066400000000000000000000023731377237306500174720ustar00rootroot00000000000000""" Test cases for PtyProcess.wait method. """ import time import unittest from ptyprocess import PtyProcess class TestWaitAfterTermination(unittest.TestCase): """Various test cases for PtyProcess.wait()""" def test_wait_true_shortproc(self): """Ensure correct (True) wait status for short-lived processes.""" child = PtyProcess.spawn(['true']) # Wait so we're reasonable sure /bin/true has terminated time.sleep(0.2) self.assertEqual(child.wait(), 0) def test_wait_false_shortproc(self): """Ensure correct (False) wait status for short-lived processes.""" child = PtyProcess.spawn(['false']) # Wait so we're reasonable sure /bin/false has terminated time.sleep(0.2) self.assertNotEqual(child.wait(), 0) def test_wait_twice_longproc(self): """Ensure correct wait status when called twice.""" # previous versions of ptyprocess raises PtyProcessError when # wait was called more than once with "Cannot wait for dead child # process.". No longer true since v0.5. child = PtyProcess.spawn(['sleep', '1']) # this call to wait() will block for 1s for count in range(2): self.assertEqual(child.wait(), 0, count)