Skip to content

Commit

Permalink
partial anyio-ization
Browse files Browse the repository at this point in the history
missing: wait for FD ready, trio only
  • Loading branch information
smurfix committed Jun 20, 2019
1 parent 37b0265 commit 6914883
Show file tree
Hide file tree
Showing 22 changed files with 71 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[run]
branch=True
source=trio_gpio
source=asyncgpio

[report]
precision = 1
Expand Down
6 changes: 3 additions & 3 deletions CHEATSHEET.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ To run yapf
-----------

* Show what changes yapf wants to make: ``yapf -rpd setup.py
trio_gpio tests``
asyncgpio tests``

* Apply all changes directly to the source tree: ``yapf -rpi setup.py
trio_gpio tests``
asyncgpio tests``


To make a release
-----------------

* Update the version in ``trio_gpio/_version.py``
* Update the version in ``asyncgpio/_version.py``

* Run ``towncrier`` to collect your release notes.

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ all:
# need to use python3 sphinx-build
PATH := /usr/share/sphinx/scripts/python3:${PATH}

PACKAGE = trio_gpio
PACKAGE = asyncgpio
PYTHON ?= python3
SPHINX ?= sphinx3-build
export PYTHONPATH=$(shell pwd)
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
trio-gpio
asyncgpio
=========

Trio-GPIO allows easy access to the GPIO pins on your Raspberry Pi or
Expand Down
4 changes: 2 additions & 2 deletions asyncgpio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Top-level package for trio-gpio."""
"""Top-level package for asyncgpio."""

import sys

Expand All @@ -18,6 +18,6 @@ def open_chip(num=0, consumer=sys.argv[0]):
Defaults to the program's name.
Returns:
a :class:`trio_gpio.gpio.Chip` instance.
a :class:`asyncgpio.gpio.Chip` instance.
"""
return Chip(num, consumer=consumer)
6 changes: 3 additions & 3 deletions ci/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ pip install -U pip setuptools wheel

if [ "$CHECK_FORMATTING" = "1" ]; then
pip install yapf==${YAPF_VERSION}
if ! yapf -rpd setup.py trio_gpio; then
if ! yapf -rpd setup.py asyncgpio; then
cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Formatting problems were found (listed above). To fix them, run
pip install yapf==${YAPF_VERSION}
yapf -rpi setup.py trio_gpio
yapf -rpi setup.py asyncgpio
in your local checkout.
Expand Down Expand Up @@ -45,7 +45,7 @@ else
mkdir empty
cd empty

pytest -W error -ra -v --pyargs trio_gpio --cov=trio_gpio --cov-config=../.coveragerc --verbose
pytest -W error -ra -v --pyargs asyncgpio --cov=asyncgpio --cov-config=../.coveragerc --verbose

bash <(curl -s https://codecov.io/bash)
fi
2 changes: 1 addition & 1 deletion debian/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
/*.debhelper-build-stamp
/*.substvars
/debhelper-build-stamp
/python3-trio-gpio
/python3-asyncgpio
14 changes: 7 additions & 7 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
trio-gpio (0.2.4-1) unstable; urgency=medium
asyncgpio (0.2.4-1) unstable; urgency=medium

* New release

-- Matthias Urlichs <[email protected]> Mon, 11 Jun 2018 21:29:33 +0200

trio-gpio (0.2.3-2) unstable; urgency=medium
asyncgpio (0.2.3-2) unstable; urgency=medium

* TL;DR: didn't RTFM

-- Matthias Urlichs <[email protected]> Mon, 11 Jun 2018 09:08:30 +0200

trio-gpio (0.2.2-1) unstable; urgency=medium
asyncgpio (0.2.2-1) unstable; urgency=medium

* Access errno

-- Matthias Urlichs <[email protected]> Mon, 11 Jun 2018 08:29:53 +0200

trio-gpio (0.2.1-1) unstable; urgency=medium
asyncgpio (0.2.1-1) unstable; urgency=medium

* Allow (and prefer) the GPIO chip label instead of its number.

-- Matthias Urlichs <[email protected]> Mon, 11 Jun 2018 04:48:44 +0200

trio-gpio (0.1.1-2) unstable; urgency=medium
asyncgpio (0.1.1-2) unstable; urgency=medium

* Cleanup 2

-- Matthias Urlichs <[email protected]> Mon, 28 May 2018 02:35:07 +0200

trio-gpio (0.1.1-1) unstable; urgency=medium
asyncgpio (0.1.1-1) unstable; urgency=medium

* Cleanup

-- Matthias Urlichs <[email protected]> Sat, 10 Mar 2018 18:36:19 +0100

trio-gpio (0.1.0-1) unstable; urgency=low
asyncgpio (0.1.0-1) unstable; urgency=low

* source package automatically created by stdeb 0.8.5

Expand Down
14 changes: 3 additions & 11 deletions debian/control
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
Source: trio-gpio
Source: asyncgpio
Maintainer: Matthias Urlichs <[email protected]>
Section: python
Priority: optional
Build-Depends: dh-python, python3-setuptools, python3-all, debhelper (>= 9),
libgpiod-dev,
python3-cffi,
python3-trio-amqp,
python3-trio-click,
python3-trio-gpio,
python3-yaml,
Standards-Version: 3.9.6
Homepage: https://github.com/M-o-a-T/trio-gpio
Homepage: https://github.com/M-o-a-T/asyncgpio

Package: python3-trio-gpio
Package: python3-asyncgpio
Architecture: all
Depends: ${misc:Depends}, ${python3:Depends},
libgpiod1,
python3-cffi,
python3-trio-amqp,
python3-trio-click,
python3-trio-gpio,
python3-yaml,
Standards-Version: 3.9.6
Description: GPIO access via Trio and libgpiod
Trio-GPIO allows easy access to the GPIO pins on your Raspberry Pi or
Expand Down
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This file was automatically generated by stdeb 0.8.5 at
# Wed, 07 Mar 2018 13:34:02 +0100
export PYBUILD_NAME=trio-gpio
export PYBUILD_NAME=asyncgpio
%:
dh $@ --with python3 --buildsystem=pybuild

4 changes: 2 additions & 2 deletions debian/watch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# please also check http://pypi.debian.net/trio-gpio/watch
# please also check http://pypi.debian.net/asyncgpio/watch
version=3
opts=uversionmangle=s/(rc|a|b|c)/~$1/ \
http://pypi.debian.net/trio-gpio/trio-gpio-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
http://pypi.debian.net/asyncgpio/asyncgpio-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = trio-gpio
SPHINXPROJ = asyncgpio
SOURCEDIR = source
BUILDDIR = build

Expand Down
2 changes: 1 addition & 1 deletion docs/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if "%SPHINXBUILD%" == "" (
)
set SOURCEDIR=source
set BUILDDIR=build
set SPHINXPROJ=trio-gpio
set SPHINXPROJ=asyncgpio

if "%1" == "" goto help

Expand Down
24 changes: 12 additions & 12 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
nitpick_ignore = [
# Format is ("sphinx reference type", "string"), e.g.:
("py:obj", "bytes-like"),
("py:class", "trio_gpio.gpio.Chip"),
("py:class", "trio_gpio.gpio.Line"),
("py:class", "asyncgpio.gpio.Chip"),
("py:class", "asyncgpio.gpio.Line"),
]

autodoc_inherit_docstrings = False
Expand Down Expand Up @@ -71,17 +71,17 @@
master_doc = 'index'

# General information about the project.
project = 'trio-gpio'
copyright = 'The trio-gpio authors'
author = 'The trio-gpio authors'
project = 'asyncgpio'
copyright = 'The asyncgpio authors'
author = 'The asyncgpio authors'

# 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.
import trio_gpio
version = trio_gpio.__version__
import asyncgpio
version = asyncgpio.__version__
# The full version, including alpha/beta/rc tags.
release = version

Expand Down Expand Up @@ -144,7 +144,7 @@
# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'trio-gpiodoc'
htmlhelp_basename = 'asyncgpiodoc'


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -171,7 +171,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'trio-gpio.tex', 'Trio Documentation',
(master_doc, 'asyncgpio.tex', 'Trio Documentation',
author, 'manual'),
]

Expand All @@ -181,7 +181,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'trio-gpio', 'trio-gpio Documentation',
(master_doc, 'asyncgpio', 'asyncgpio Documentation',
[author], 1)
]

Expand All @@ -192,7 +192,7 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'trio-gpio', 'trio-gpio Documentation',
author, 'trio-gpio', 'GPIO access via Trio and libgpiod',
(master_doc, 'asyncgpio', 'asyncgpio Documentation',
author, 'asyncgpio', 'GPIO access via Trio and libgpiod',
'Miscellaneous'),
]
2 changes: 1 addition & 1 deletion docs/source/history.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Release history
===============

.. currentmodule:: trio_gpio
.. currentmodule:: asyncgpio

.. towncrier release notes start
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
============================================
trio-gpio: GPIO access via Trio and libgpiod
asyncgpio: GPIO access via Trio and libgpiod
============================================

Trio-GPIO is a simple wrapper around ``libgpiod``.
Expand Down
26 changes: 13 additions & 13 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

Using Trio-GPIO
Using AsyncGPIO
===============

.. module: trio_gpio
.. module: asyncgpio
Using Trio-GPIO generally consists of three steps:
Using AsyncGPIO generally consists of three steps:
Accessing the chip, referring to a GPIO line within that chip.
and actually using the line for input, output, or monitoring.

Expand All @@ -14,12 +14,12 @@ Accessing a GPIO chip
GPIO chips are accessed by their number. You usually find them as ``/dev/gpiochipN``
where N starts at zero.

Trio-GPIO refers to GPIO chips by their sequence number.
AsyncGPIO refers to GPIO chips by their sequence number.
You need to refer to your hardware's documentation to discover which chip to use,
assuming there's more than one.

::
import trio-gpio as gpio
import asyncgpio as gpio

def main():
with gpio.open_chip(0, consumer="example") as chip:
Expand All @@ -28,7 +28,7 @@ assuming there's more than one.
The ``consumer`` argument is optional. It describes your code to the kernel, so that
a program which enumerates GPIO users can display who currently uses the pin in question.

.. autofunction:: trio_gpio.open_chip
.. autofunction:: asyncgpio.open_chip

Referring to a line
-------------------
Expand All @@ -43,12 +43,12 @@ You need to refer to your hardware's documentation to discover which line to use
as an output that's actually an input) may damage your computer or its
periphera(s).

.. automethod: trio_gpio.gpio.Chip.line
.. automethod: asyncgpio.gpio.Chip.line
.. note::

``libgpiod`` has functions for bulk referrals which allow you to access multiple lines
at the same time. Yo may wonder why these are missing from Trio-GPIO. The answer is that
at the same time. Yo may wonder why these are missing from AsyncGPIO. The answer is that
the kernel's GPIO interface does not have functions that affect multiple lines; if you
need them for convenience it's easer to write appropriate Python methods, than to do the
packing+unpacking of values into C-language structures that these bulk methods require.
Expand All @@ -57,7 +57,7 @@ You need to refer to your hardware's documentation to discover which line to use
Using a line
------------

A :class:`trio_gpio.gpio.Line` object just describes a GPIO line; before you can actually
A :class:`asyncgpio.gpio.Line` object just describes a GPIO line; before you can actually
use it, you need to request it from the kernel (which also prevents anybody else from using
the line).

Expand All @@ -69,7 +69,7 @@ the line).
you need to do ``echo 12 >/sys/class/gpio/unexport`` before your program can access
line 12.

.. automethod: trio.gpio.Line.open
.. automethod: asyncgpio.Line.open
Output
~~~~~~
Expand All @@ -89,7 +89,7 @@ code might be a better idea::
with chip.line(20).open(direction=gpio.DIRECTION_OUTPUT) as line:
line.value = 1
try:
await trio.sleep(5*60)
await anyio.sleep(5*60)
finally:
line.value = 0

Expand Down Expand Up @@ -124,9 +124,9 @@ Therefore, it's better to let the kernel signal changes to a GPIO device::
async for e in in_:
print(e, "on" if e.value else "off", "at", e.time.strftime("%H:%M:%S"))

:: automethod: trio_gpio.gpio.Line.monitor
:: automethod: asyncgpio.gpio.Line.monitor

:: autoclass: trio_gpio.gpio.Event
:: autoclass: asyncgpio.gpio.Event
:members:

.. note::
Expand Down
Loading

0 comments on commit 6914883

Please sign in to comment.