Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix issue #7 on crc checksum failure #11

Merged
merged 15 commits into from
Dec 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
/.pydevproject
*.pyc
/dist
/build
/xmodem.egg-info
/.coverage
/.tox
*.py.swp
27 changes: 20 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
language: python
python:
- "2.6"
- "2.7"
# install required packages

env:
- TOXENV=py26
- TOXENV=py27
- TOXENV=py33
- TOXENV=pypy
- TOXENV=py34

install:
- sudo apt-get install lrzsz
# command to run tests
- pip install -q tox coveralls
- sudo apt-get install -qq -y lrzsz

script:
- make tests
- tox -e $TOXENV

after_success:
- coveralls

notifications:
email:
- contact@jeffquast.com
- maze@pyth0n.org
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
tests:
PYTHONPATH=. python test/test.py test/test.py
PYTHONPATH=. python test/test-recv.py
PYTHONPATH=. python test/test-send.py
tox

upload:
python setup.py sdist upload
Expand Down
17 changes: 13 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.. image:: https://travis-ci.org/tehmaze/xmodem.png?branch=master
:target: https://travis-ci.org/tehmaze/xmodem

.. image:: https://coveralls.io/repos/tehmaze/xmodem/badge.png
:target: https://coveralls.io/r/tehmaze/xmodem

================================
XMODEM protocol implementation
================================
Expand Down Expand Up @@ -35,8 +41,11 @@ For more information, take a look at the documentation_.

.. _documentation: http://packages.python.org/xmodem/xmodem.html

.. image:: https://travis-ci.org/tehmaze/xmodem.png?branch=master
:target: https://travis-ci.org/tehmaze/xmodem
Changes
=======

.. image:: https://coveralls.io/repos/tehmaze/xmodem/badge.png
:target: https://coveralls.io/r/tehmaze/xmodem
0.4.0
* enhancement: support for python 3
`PR #8 <https://github.com/tehmaze/xmodem/pull/8>`_.
* bugfix: CRC failures in XMODEM.recv() were not renegotiated correctly
`PR #11 <https://github.com/tehmaze/xmodem/issues/11>`_.
4 changes: 2 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
# built documents.
#
# The short X.Y version.
version = '0.3'
version = '0.4'
# The full version, including alpha/beta/rc tags.
release = '0.3.3'
release = '0.4.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
3 changes: 3 additions & 0 deletions requirements-testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest-cov
pytest
tox
73 changes: 23 additions & 50 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,26 @@
from setuptools import setup, find_packages
import os
import codecs
from setuptools import setup

setup(
name = 'xmodem',
version = '0.3.3',
author = 'Wijnand Modderman',
author_email = 'maze@pyth0n.org',
description = ('XMODEM protocol implementation.'),
long_description = '''
================================
XMODEM protocol implementation
================================

Documentation available at http://packages.python.org/xmodem/

The source code repository is at https://github.com/tehmaze/xmodem

Usage
=====

Create a function to get and put character data (to a serial line for
example)::

>>> from xmodem import XMODEM
>>> def getc(size, timeout=1):
... return data or None
...
>>> def putc(data, timeout=1):
... return size or None
...
>>> modem = XMODEM(getc, putc)

Now, to upload a file, use the ``send`` method::
HERE = os.path.dirname(__file__)
README_RST = os.path.join(HERE, 'README.rst')

>>> stream = open('/etc/fstab', 'rb')
>>> modem.send(stream)

To download a file, use the ``recv`` method::

>>> stream = open('output', 'wb')
>>> modem.recv(stream)

For more information, take a look at the documentation_.

.. _documentation: http://packages.python.org/xmodem/xmodem.html

''',
license = 'MIT',
keywords = 'xmodem protocol',
packages = ['xmodem'],
package_data = {'': ['doc/*.TXT']},
setup(
name='xmodem',
version='0.4.0',
author='Wijnand Modderman, Jeff Quast',
author_email='maze@pyth0n.org',
description=('XMODEM protocol implementation.'),
long_description = codecs.open(README_RST, 'rb', 'utf8').read(),
license='MIT',
keywords='xmodem protocol',
packages=['xmodem'],
package_data={'': ['doc/*.TXT', 'doc/*.txt', 'README.rst']},
include_package_data=True,
data_files=[
('doc', ('doc/XMODEM.TXT',
'doc/XMODEM1K.TXT',
'doc/XMODMCRC.TXT',
'doc/ymodem.txt')),
],
)

Empty file added test/functional/__init__.py
Empty file.
56 changes: 56 additions & 0 deletions test/functional/accessories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import subprocess
import errno


def _multi_which(prog_names):
for prog_name in prog_names:
proc = subprocess.Popen(('which', prog_name), stdout=subprocess.PIPE)
stdout, stderr = proc.communicate()
if proc.returncode == 0:
return stdout.strip()
return None


def _get_recv_program():
bin_path = _multi_which(('rb', 'lrb'))
assert bin_path is not None, (
"program required: {0!r}. "
"Try installing lrzsz package.".format(bin_path))
return bin_path


def _get_send_program():
bin_path = _multi_which(('sb', 'lsb'))
assert bin_path is not None, (
"program required: {0!r}. "
"Try installing lrzsz package.".format(bin_path))
return bin_path

recv_prog = _get_recv_program()
send_prog = _get_send_program()

CHUNKSIZE = 521


def fill_binary_data(stream):
for byte in range(0x00, 0xff + 1, 10):
stream.write(bytearray([byte] * CHUNKSIZE))
stream.seek(0)
return stream


def verify_binary_data(stream, padding):
stream.seek(0)
for byte in range(0x00, 0xff + 1, 10):
assert stream.read(CHUNKSIZE) == bytearray([byte] * CHUNKSIZE)
while True:
try:
# BSD-style EOF
data = stream.read(1)
assert data in (b'', padding)
if data == b'':
# BSD-style EOF
break
except OSError as err:
# Linux-style EOF
assert err.errno == errno.EIO
42 changes: 0 additions & 42 deletions test/functional/test-recv.py

This file was deleted.

48 changes: 0 additions & 48 deletions test/functional/test-send.py

This file was deleted.

Loading