Skip to content

Commit

Permalink
Setup asyncio command line output.
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan Bloemberg committed Nov 14, 2016
1 parent 135eef2 commit 40f138e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .envrc
@@ -0,0 +1,2 @@
layout python3
python setup.py develop
43 changes: 41 additions & 2 deletions rflink/__main__.py
@@ -1,6 +1,45 @@
"""Command line interface for rflink library."""
"""Command line interface for rflink library.
Usage:
rflink [--port=<port>, --baud=<baud>]
rflink (-h | --help)
rflink --version
Options:
-p --port=<port> Serial port to connect to [default: /dev/ttyACM0].
--baud=<baud> Serial baud rate [default: 57600].
-h --help Show this screen.
--version Show version.
"""

import asyncio

import pkg_resources
from docopt import docopt


@asyncio.coroutine
def output():
"""Provide output to console."""
import itertools
counter = itertools.count()
while True:
print(next(counter))
yield from asyncio.sleep(1)


def main():
"""Parse argument and setup main program loop."""
pass
arguments = docopt(__doc__, version=pkg_resources.require('rflink')[0].version)
print(arguments)
loop = asyncio.get_event_loop()
tasks = asyncio.gather(output())
try:
loop.run_until_complete(tasks)
except KeyboardInterrupt:
tasks.cancel()
loop.run_forever()
tasks.exception()
finally:
loop.close()
5 changes: 3 additions & 2 deletions setup.cfg
@@ -1,5 +1,6 @@
[pylama]
linters = pydocstyle,pycodestyle,pyflakes,mccabe
linters = pydocstyle,pycodestyle,pyflakes,mccabe,isort
ignore = D213

[pylama:pycodestyle]
max-line-length = 100
max_line_length = 100
8 changes: 6 additions & 2 deletions setup.py
@@ -1,9 +1,10 @@
"""Library and CLI tools for interacting with RFlink 433MHz transceiver."""

from setuptools import setup, find_packages
from codecs import open
from os import path

from setuptools import find_packages, setup

here = path.abspath(path.dirname(__file__))

# Get the long description from the README file
Expand Down Expand Up @@ -50,7 +51,10 @@

packages=find_packages(exclude=['contrib', 'docs', 'tests']),

# install_requires=[''],
install_requires=[
'docopt',
'pyserial-asyncio',
],

# # List additional groups of dependencies here (e.g. development
# # dependencies). You can install these using the following syntax,
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Expand Up @@ -9,4 +9,6 @@ usedevelop = True

[testenv:lint]
commands = pylama setup.py rflink tests
deps = pylama
deps =
pylama
isort

0 comments on commit 40f138e

Please sign in to comment.