streamexpect
============
[![Build Status](https://travis-ci.org/digidotcom/python-streamexpect.svg?branch=master)](https://travis-ci.org/digidotcom/python-streamexpect)
[![Coverage Status](https://img.shields.io/coveralls/digidotcom/python-streamexpect.svg)](https://coveralls.io/r/digidotcom/python-streamexpect)
[![Code Climate](https://img.shields.io/codeclimate/github/digidotcom/python-streamexpect.svg)](https://codeclimate.com/github/digidotcom/python-streamexpect)
[![GitHub Issues](https://img.shields.io/github/issues/digidotcom/python-streamexpect.svg)](https://github.com/digidotcom/python-streamexpect/issues)
[![PyPI](https://img.shields.io/pypi/v/streamexpect.svg)](https://pypi.python.org/pypi/streamexpect/)
[![License](https://img.shields.io/badge/license-MPL%202.0-blue.svg)](https://github.com/digidotcom/python-streamexpect/blob/master/LICENSE.txt)
streamexpect is a library providing cross-platform "expect-like" functionality
for generic Python streams and sockets . It is similar to the
[Pexpect](https://pexpect.readthedocs.org) library, except where Pexpect
explicitly requires an underlying file (usually a TTY), streamexpect uses
duck-typing and requires only a `read` or `recv` method.
[View the Full Documentation](https://digidotcom.github.io/python-streamexpect)
The original version of streamexpect was generously donated by
[Digi](http://www.digi.com) [Wireless Design Services](http://www.digi.com/wds).
The software is provided as Alpha software and has not undergone formal
testing. It does, however, ship with extensive unit testing.
[View the Changelog](https://github.com/digidotcom/python-streamexpect/blob/master/CHANGELOG.md)
Installation
============
Installation is performed using pip. The latest released version of
streamexpect can be obtained with the following command:
```sh
$ pip install streamexpect
```
To install the development version from GitHub:
```sh
$ pip install -U -e 'git+https://github.com/digidotcom/python-streamexpect#egg=streamexpect'
```
Example
=======
The following example shows opening a serial port (on a Windows PC), sending
the `uname` command, and verifying that _Linux_ is in the returned data.
```python
import serial
import streamexpect
# timeout=0 is essential, as streams are required to be non-blocking
ser = serial.Serial('COM1', baudrate=115200, timeout=0)
with streamexpect.wrap(ser) as stream:
stream.write('\r\nuname -a\r\n')
match = stream.expect_bytes('Linux', timeout=1.0)
print(u'Found Linux at index {}'.format(match.start))
```
Design Goals
============
* Be Cross-Platform
The library should not depend on any features (besides Python) that exclude a
platform. Yes, that means Windows is a first-class citizen.
* Be Explicit In Encoding
When dealing with streams of data, the distinction between when the stream
goes from being a series of binary bytes to a set of encoded characters can
be unclear. The library should be explicit in the handling of binary versus
characters, such that mixing the two types is not allowed without explicit
options to enable encoding and decoding.
* Common Use Cases Should Be Simple
For 95% of users, the `streamexpect.wrap` function should accomplish the
desired goals. Intelligent default options should be used so the library just
"does the right thing".
* Complicated Use Cases Should Be Possible
The objects returned by the `streamexpect.wrap` function should themselves be
easy to use and extend. Protocol requirements between classes should be
explicit and documented.
Development
===========
Development of streamexpect takes place in the open on GitHub. Please use pull
requests to submit changes to code and documentation.
The process for building and testing streamexpect has been automated as much as
possible. [tox](https://testrun.org/tox/) handles building and testing the
code, as well as generating documentation and automatically testing for code
style issues. tox can be installed with pip:
pip install tox
The generic tox command looks like:
tox
This will attempt to build and test streamexpect against multiple different
versions of Python, and will error on versions not found. To test against only
a single version of Python, specify the version at the tox command line. For
example, to test only Python 2.7:
tox -e py27
Multiple versions may be specified, separated by a comma:
tox -e py27,py35
Documentation generation and code style checking are not performed by default,
and so must be explicitly provided to the tox command. Documentation generation
requires either Python 2.7, or Python 3.3 or greater.
tox -e docs,style
License
=======
This software is open-source software. Copyright Digi International, 2015.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this file,
you can obtain one at http://mozilla.org/MPL/2.0/.
Raw data
{
"_id": null,
"home_page": "https://github.com/digidotcom/python-streamexpect",
"name": "streamexpect",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "expect pexpect search stream serial pyserial socket",
"author": "Digi International Inc.",
"author_email": "noreply@digi.com",
"download_url": "https://files.pythonhosted.org/packages/f6/aa/0bef4d69a694b170ca64aa172329bfca241b456dd655c7a7ad9ad382f3d4/streamexpect-0.3.0.tar.gz",
"platform": null,
"description": "streamexpect\n============\n\n[![Build Status](https://travis-ci.org/digidotcom/python-streamexpect.svg?branch=master)](https://travis-ci.org/digidotcom/python-streamexpect)\n[![Coverage Status](https://img.shields.io/coveralls/digidotcom/python-streamexpect.svg)](https://coveralls.io/r/digidotcom/python-streamexpect)\n[![Code Climate](https://img.shields.io/codeclimate/github/digidotcom/python-streamexpect.svg)](https://codeclimate.com/github/digidotcom/python-streamexpect)\n[![GitHub Issues](https://img.shields.io/github/issues/digidotcom/python-streamexpect.svg)](https://github.com/digidotcom/python-streamexpect/issues)\n[![PyPI](https://img.shields.io/pypi/v/streamexpect.svg)](https://pypi.python.org/pypi/streamexpect/)\n[![License](https://img.shields.io/badge/license-MPL%202.0-blue.svg)](https://github.com/digidotcom/python-streamexpect/blob/master/LICENSE.txt)\n\nstreamexpect is a library providing cross-platform \"expect-like\" functionality\nfor generic Python streams and sockets . It is similar to the\n[Pexpect](https://pexpect.readthedocs.org) library, except where Pexpect\nexplicitly requires an underlying file (usually a TTY), streamexpect uses\nduck-typing and requires only a `read` or `recv` method.\n\n[View the Full Documentation](https://digidotcom.github.io/python-streamexpect)\n\nThe original version of streamexpect was generously donated by\n[Digi](http://www.digi.com) [Wireless Design Services](http://www.digi.com/wds).\nThe software is provided as Alpha software and has not undergone formal\ntesting. It does, however, ship with extensive unit testing.\n\n[View the Changelog](https://github.com/digidotcom/python-streamexpect/blob/master/CHANGELOG.md)\n\nInstallation\n============\n\nInstallation is performed using pip. The latest released version of\nstreamexpect can be obtained with the following command:\n\n```sh\n$ pip install streamexpect\n```\n\nTo install the development version from GitHub:\n\n```sh\n$ pip install -U -e 'git+https://github.com/digidotcom/python-streamexpect#egg=streamexpect'\n```\n\nExample\n=======\n\nThe following example shows opening a serial port (on a Windows PC), sending\nthe `uname` command, and verifying that _Linux_ is in the returned data.\n\n```python\nimport serial\nimport streamexpect\n\n# timeout=0 is essential, as streams are required to be non-blocking\nser = serial.Serial('COM1', baudrate=115200, timeout=0)\n\nwith streamexpect.wrap(ser) as stream:\n stream.write('\\r\\nuname -a\\r\\n')\n match = stream.expect_bytes('Linux', timeout=1.0)\n print(u'Found Linux at index {}'.format(match.start))\n```\n\n\nDesign Goals\n============\n\n* Be Cross-Platform\n\n The library should not depend on any features (besides Python) that exclude a\n platform. Yes, that means Windows is a first-class citizen.\n\n* Be Explicit In Encoding\n\n When dealing with streams of data, the distinction between when the stream\n goes from being a series of binary bytes to a set of encoded characters can\n be unclear. The library should be explicit in the handling of binary versus\n characters, such that mixing the two types is not allowed without explicit\n options to enable encoding and decoding.\n\n* Common Use Cases Should Be Simple\n\n For 95% of users, the `streamexpect.wrap` function should accomplish the\n desired goals. Intelligent default options should be used so the library just\n \"does the right thing\".\n\n* Complicated Use Cases Should Be Possible\n\n The objects returned by the `streamexpect.wrap` function should themselves be\n easy to use and extend. Protocol requirements between classes should be\n explicit and documented.\n\n\nDevelopment\n===========\n\nDevelopment of streamexpect takes place in the open on GitHub. Please use pull\nrequests to submit changes to code and documentation.\n\nThe process for building and testing streamexpect has been automated as much as\npossible. [tox](https://testrun.org/tox/) handles building and testing the\ncode, as well as generating documentation and automatically testing for code\nstyle issues. tox can be installed with pip:\n\n pip install tox\n\nThe generic tox command looks like:\n\n tox\n\nThis will attempt to build and test streamexpect against multiple different\nversions of Python, and will error on versions not found. To test against only\na single version of Python, specify the version at the tox command line. For\nexample, to test only Python 2.7:\n\n tox -e py27\n\nMultiple versions may be specified, separated by a comma:\n\n tox -e py27,py35\n\nDocumentation generation and code style checking are not performed by default,\nand so must be explicitly provided to the tox command. Documentation generation\nrequires either Python 2.7, or Python 3.3 or greater.\n\n tox -e docs,style\n\n\nLicense\n=======\n\nThis software is open-source software. Copyright Digi International, 2015.\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this file,\nyou can obtain one at http://mozilla.org/MPL/2.0/.\n",
"bugtrack_url": null,
"license": "",
"summary": "expect-like tools over a Python stream",
"version": "0.3.0",
"project_urls": {
"Homepage": "https://github.com/digidotcom/python-streamexpect"
},
"split_keywords": [
"expect",
"pexpect",
"search",
"stream",
"serial",
"pyserial",
"socket"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f6aa0bef4d69a694b170ca64aa172329bfca241b456dd655c7a7ad9ad382f3d4",
"md5": "6d3b190281a653beae960c8fb5dc05e6",
"sha256": "a0b5a7350e0c2169c5c6d339a70fd7e3a43bf7a6405c840d28a44d5ffd63de8f"
},
"downloads": -1,
"filename": "streamexpect-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "6d3b190281a653beae960c8fb5dc05e6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 18385,
"upload_time": "2024-02-22T21:30:28",
"upload_time_iso_8601": "2024-02-22T21:30:28.009188Z",
"url": "https://files.pythonhosted.org/packages/f6/aa/0bef4d69a694b170ca64aa172329bfca241b456dd655c7a7ad9ad382f3d4/streamexpect-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-22 21:30:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "digidotcom",
"github_project": "python-streamexpect",
"travis_ci": true,
"coveralls": true,
"github_actions": false,
"tox": true,
"lcname": "streamexpect"
}