happyleavesaoc/python-snapcast

can't get example code working

binbs opened this issue · 2 comments

binbs commented

Hi, first of all i pretty much like the idea of controlling the snapcastserver via python.
So i gladly found your implementation for python.

ATM i'm trying to control a remote snapserver via your example script. (0.11.1)
It doesn't throw an error but only returns an empty List.

on 1st Line i use
server = snapcast.control.Snapserver('master',1705)
and i get
Snapserver None (1705)

in the server.py-> init theres a loop to be given on Object creation and not set to any default value.
Could you please tell me how i can create one?
This sort of python-programming is above my skills (for now) so i really appreciated your help.

Thank you very much

Hi there, the README is a bit out of date. We now use asyncio. Here's a minimal example:

import snapcast.control
import asyncio

loop = asyncio.get_event_loop()

def run_test(loop):
    server = yield from snapcast.control.create_server(loop, 'localhost')

asyncio.ensure_future(run_test(loop))
loop.run_forever()

The unit tests should also provide some nice usage examples. I also opened an issue to improve the docs.

binbs commented

Thank you very much for the fast help,
i will look up unittests then and close this