pylover / aiolirc

AsyncIO python wrapper for lirc.
GNU General Public License v3.0
6 stars 0 forks source link

Provided Quick Start examples do not work #4

Open jpstotz opened 7 years ago

jpstotz commented 7 years ago

I tried to make aiolirc work using the "Quick Start" examples provided on https://github.com/pylover/aiolirc however the provided code has errors and does not even start. I tried it on two different platforms, following the tutorial, with the same result. First on a raspberry using a self-compiled version of python3.5.2 and second on an Ubuntu 16.04 using the built in python3 (3.5.2).

The first example:

#!/usr/bin/python3
from aiolirc import very_quickstart, listen_for

@listen_for('play')
async def do_play(loop):
    print("test")
    # Do play stuff

very_quickstart('my-prog')  # my-prog is configured in your lircrc file.

Always ends up in an error like this:

  File "test1.py", line 9, in <module>
    very_quickstart('my-prog')  # my-prog is configured in your lircrc file.
  File "/home/ubuntu/pythontest/lib/python3.5/site-packages/aiolirc/__init__.py", line 19, in very_quickstart
    main_loop.run_until_complete(quickstart(loop=main_loop))
  File "/usr/lib/python3.5/asyncio/base_events.py", line 387, in run_until_complete
    return future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/home/ubuntu/pythontest/lib/python3.5/site-packages/aiolirc/__init__.py", line 12, in quickstart
    async with LIRCClient(*args, **kwargs) as client:
  File "aiolirc/lirc_client.pyx", line 84, in aiolirc.lirc_client.LIRCClient.__cinit__ (aiolirc/lirc_client.c:2202)

The second example also fails:

#!/usr/bin/python3
import asyncio

from aiolirc.lirc_client import LIRCClient
from aiolirc.dispatcher import IRCDispatcher, listen_for

@listen_for('amp power', repeat=5)
async def amp_power(loop):
    print("test")
    # Do your stuff

@listen_for('amp source')
async def amp_source(loop):
    print("test")
    # Do your stuff

async with LIRCClient('my-prog') as client:
    dispatcher = IRCDispatcher(client)
    await dispatcher.listen()

The error is as follows:

  File "test2.py", line 18
    async with LIRCClient('my-prog') as client:
             ^
SyntaxError: invalid syntax

Hence I assume that something is missing or incorrect regarding the examples and the install procedure. However I am unable to understand what is going wrong here.

pylover commented 7 years ago

Thanks, it will fixed soon.

pylover commented 7 years ago

It's so weird.

I think the error mssage in he first try is incomplete

pylover commented 7 years ago

The SyntaxError in the second try is about python version and or indent.