Skip to content

Commit

Permalink
Py2 (#249)
Browse files Browse the repository at this point in the history
* Migrated output classes from namedtuples to slotted objects
* Updated changelog
* Updated docs
  • Loading branch information
pkittenis authored Dec 9, 2020
1 parent 94b5617 commit 7e3ab17
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 25 deletions.
9 changes: 9 additions & 0 deletions Changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Change Log
============

2.3.2
+++++

Fixes
-----

* Client output implementation Python 2 support.


2.3.1
+++++

Expand Down
8 changes: 3 additions & 5 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
Parallel-SSH Documentation
===========================

.. image:: https://img.shields.io/badge/License-LGPL%20v2-blue.svg
.. image:: https://img.shields.io/badge/License-LGPL%20v2.1-blue.svg
:target: https://pypi.python.org/pypi/parallel-ssh
:alt: License
.. image:: https://img.shields.io/pypi/v/parallel-ssh.svg
:target: https://pypi.python.org/pypi/parallel-ssh
:alt: Latest Version
.. image:: https://travis-ci.org/ParallelSSH/parallel-ssh.svg?branch=master
:target: https://travis-ci.org/ParallelSSH/parallel-ssh
.. image:: https://ci.appveyor.com/api/projects/status/github/parallelssh/ssh2-python?svg=true&branch=master
:target: https://ci.appveyor.com/project/pkittenis/ssh2-python
.. image:: https://circleci.com/gh/ParallelSSH/parallel-ssh/tree/master.svg?style=svg
:target: https://circleci.com/gh/ParallelSSH/parallel-ssh
.. image:: https://codecov.io/gh/ParallelSSH/parallel-ssh/branch/master/graph/badge.svg
:target: https://codecov.io/gh/ParallelSSH/parallel-ssh
.. image:: https://img.shields.io/pypi/wheel/parallel-ssh.svg
Expand Down
46 changes: 26 additions & 20 deletions pssh/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,37 @@

"""Output module of ParallelSSH"""

from collections import namedtuple
from os import linesep

from . import logger


HostOutputBuffers = namedtuple('HostOutputBuffers', ['stdout', 'stderr'], )
HostOutputBuffers.__doc__ = """
:param stdout: Stdout data
:type stdout: :py:class:`BufferData`
:param stderr: Stderr data
:type stderr: :py:class:`BufferData`
"""
HostOutputBuffers.stdout.__doc__ = "Stdout :py:class:`BufferData`"
HostOutputBuffers.stderr.__doc__ = "Stderr :py:class:`BufferData`"

BufferData = namedtuple('BufferData', ['reader', 'rw_buffer'])
BufferData.__doc__ = """
:param reader: Reader
:type reader: :py:class:`gevent.Greenlet`
:param rw_bufffer: Read/write buffer
:type rw_buffer: :py:class:`pssh.clients.reader.ConcurrentRWBuffer`
"""
BufferData.rw_buffer.__doc__ = "Read/write buffer"
BufferData.reader.__doc__ = "Greenlet reading data from channel and writing to rw_buffer"
class HostOutputBuffers(object):
__slots__ = ('stdout', 'stderr')

def __init__(self, stdout, stderr):
"""
:param stdout: Stdout data
:type stdout: :py:class:`BufferData`
:param stderr: Stderr data
:type stderr: :py:class:`BufferData`
"""
self.stdout = stdout
self.stderr = stderr


class BufferData(object):
__slots__ = ('reader', 'rw_buffer')

def __init__(self, reader, rw_buffer):
"""
:param reader: Greenlet reading data from channel and writing to rw_buffer
:type reader: :py:class:`gevent.Greenlet`
:param rw_bufffer: Read/write buffer
:type rw_buffer: :py:class:`pssh.clients.reader.ConcurrentRWBuffer`
"""
self.reader = reader
self.rw_buffer = rw_buffer


class HostOutput(object):
Expand Down

0 comments on commit 7e3ab17

Please sign in to comment.