scrool / xled

🎄Unofficial control for Twinkly - Smart Decoration LED lights.
MIT License
209 stars 47 forks source link

Discovery doesn't work on python 3 #9

Closed scrool closed 5 years ago

scrool commented 5 years ago

Trying to use discovery with CLI ends up in loop tracebacks:

$ xled off
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib64/python3.4/threading.py", line 911, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.4/threading.py", line 859, in run
    self._target(*self._args, **self._kwargs)
  File "…/xled/xled/discover.py", line 278, in start
    pc.start()
  File "…/.virtualenvs/xled@python-3.4/lib/python3.4/site-packages/tornado-5.1.1-py3.4-linux-x86_64.egg/tornado/ioloop.py", line 1206, in start
    self.io_loop = IOLoop.current()
  File "…/.virtualenvs/xled@python-3.4/lib/python3.4/site-packages/tornado-5.1.1-py3.4-linux-x86_64.egg/tornado/ioloop.py", line 282, in current
    loop = asyncio.get_event_loop()
  File "/usr/lib64/python3.4/asyncio/events.py", line 626, in get_event_loop
    return get_event_loop_policy().get_event_loop()
  File "/usr/lib64/python3.4/asyncio/events.py", line 572, in get_event_loop
    % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'Thread-1'.

^C
Aborted!
retorquere commented 5 years ago

When I try this under python3:

import xled
discovered_device = xled.discover.discover()

I get

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/home/emile/anaconda3/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/emile/anaconda3/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/emile/github/xled/xled/discover.py", line 316, in start
    stream.on_recv(self.control_message)
  File "/home/emile/anaconda3/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 177, in on_recv
    self._add_io_state(self.io_loop.READ)
  File "/home/emile/anaconda3/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 518, in _add_io_state
    self._update_handler(self._state)
  File "/home/emile/anaconda3/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 530, in _update_handler
    self.io_loop.update_handler(self.socket, state)
  File "/home/emile/anaconda3/lib/python3.6/site-packages/tornado/platform/asyncio.py", line 92, in update_handler
    fd, self._handle_events, fd, IOLoop.READ)
  File "/home/emile/anaconda3/lib/python3.6/asyncio/selector_events.py", line 337, in add_reader
    return self._add_reader(fd, callback, *args)
  File "/home/emile/anaconda3/lib/python3.6/asyncio/selector_events.py", line 264, in _add_reader
    key = self._selector.get_key(fd)
  File "/home/emile/anaconda3/lib/python3.6/selectors.py", line 189, in get_key
    return mapping[fileobj]
  File "/home/emile/anaconda3/lib/python3.6/selectors.py", line 70, in __getitem__
    fd = self._selector._fileobj_lookup(fileobj)
  File "/home/emile/anaconda3/lib/python3.6/selectors.py", line 224, in _fileobj_lookup
    return _fileobj_to_fd(fileobj)
  File "/home/emile/anaconda3/lib/python3.6/selectors.py", line 39, in _fileobj_to_fd
    "{!r}".format(fileobj)) from None
ValueError: Invalid file object: <zmq.sugar.socket.Socket object at 0x7fc3bfd02d68>
scrool commented 5 years ago

This may depend on other on other package versions. How did you install those dependencies?

retorquere commented 5 years ago

pip install -r requirements_dev.txt

scrool commented 5 years ago

You need to run python setup.py install as well.

retorquere commented 5 years ago

Done, getting the same error still.

scrool commented 5 years ago

What about output of pip freeze?

retorquere commented 5 years ago
addict==2.2.0
alabaster==0.7.10
anaconda-client==1.6.9
anaconda-navigator==1.6.9
anaconda-project==0.8.2
appdirs==1.4.3
apsw==3.9.2.post1
argh==0.26.2
arpreq==0.3.3
arrow==0.8.0
asn1crypto==0.24.0
aspy.yaml==1.1.1
astroid==1.6.1
astropy==2.0.3
atpublic==1.0
attrs==17.4.0
Babel==2.5.3
backports.shutil-get-terminal-size==1.0.0
beautifulsoup4==4.6.0
bitarray==0.8.1
bkcharts==0.2
blaze==0.11.3
bleach==2.1.2
bokeh==0.12.13
boto==2.48.0
Bottleneck==1.2.1
branca==0.3.0
bumpversion==0.5.3
cached-property==1.5.1
cairocffi==0.9.0
CairoSVG==2.1.3
caldav==0.5.0
certifi==2018.1.18
cffi==1.11.4
cfgv==1.1.0
chardet==3.0.4
Cheetah3==3.1.0
circleclient==0.1.6
ckanapi==4.1
click==6.7
click-log==0.3.2
clipboard==0.0.4
cloudpickle==0.5.2
clyent==1.2.2
cmislib==0.6.0
colorama==0.3.9
compoundfiles==0.3
conda==4.5.11
conda-build==3.0.27
conda-verify==2.0.0
ConfigArgParse==0.12.0
contextlib2==0.5.5
coursera-dl==0.9.0
coverage==4.4.2
cryptography==2.1.4
cssselect2==0.2.1
cycler==0.10.0
Cython==0.27.3
cytoolz==0.9.0
dask==0.16.1
datashape==0.5.4
decorator==4.2.1
defusedxml==0.5.0
Deprecated==1.2.3
distributed==1.20.2
dnspython==1.16.0
docopt==0.6.2
docutils==0.14
dotmap==1.2.20
entrypoints==0.2.3
et-xmlfile==1.0.1
etaprogress==1.1.1
exchangelib==1.12.1
fastcache==1.0.2
feather-format==0.4.0
filelock==2.0.13
flake8==3.5.0
Flask==0.12.2
Flask-Cors==3.0.3
flufl.lock==3.2
folium==0.6.0
future==0.15.2
geographiclib==1.49
geojson==2.4.0
geopy==1.14.0
gevent==1.2.2
glob2==0.6
gmaps==0.8.0
gmpy2==2.0.8
gmusicapi==11.0.3
gpsoauth==0.4.1
greenlet==0.4.12
gunicorn==19.9.0
h5py==2.7.1
heapdict==1.0.0
html5lib==1.0.1
httplib2==0.11.3
identify==1.1.7
idna==2.6
imageio==2.2.0
imagesize==0.7.1
importlib-metadata==0.7
importlib-resources==1.0.2
infinity==1.4
influxdb==5.0.0
intervals==0.8.0
ipykernel==4.8.0
ipython==6.2.1
ipython-genutils==0.2.0
ipywidgets==7.2.1
iso8601==0.1.12
isodate==0.6.0
isort==4.2.15
itsdangerous==0.24
jdcal==1.3
jedi==0.11.1
Jinja2==2.10
Js2Py==0.59
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.2.2
jupyter-console==5.2.0
jupyter-core==4.4.0
jupyterlab==0.31.5
jupyterlab-launcher==0.10.2
keyring==10.6.0
lazy-object-proxy==1.3.1
leo==5.7
livereload==2.5.2
llvmlite==0.21.0
locket==0.2.0
lxml==4.1.1
Markdown==3.0.1
MarkupSafe==1.0
matlab-kernel==0.15.0
matlabengineforpython===R2018a
matplotlib==2.1.2
mccabe==0.6.1
MechanicalSoup==0.11.0
metakernel==0.20.14
mistune==0.8.3
mkdocs==1.0.4
mock==2.0.0
monetdblite==0.6.0.post6
mpmath==1.0.0
msgpack-python==0.5.1
multipledispatch==0.4.9
mutagen==1.41.1
namedlist==1.7
namedtupled==0.3.3
navigator-updater==0.1.0
nbconvert==5.3.1
nbformat==4.4.0
netaddr==0.7.19
networkx==2.1
nltk==3.2.5
nodeenv==1.3.3
nose==1.3.7
notebook==5.4.0
ntlm-auth==1.2.0
numba==0.36.2
numexpr==2.6.4
numpy==1.14.0
numpydoc==0.7.0
oauth2client==4.1.3
oauthlib==2.1.0
odo==0.5.1
olefile==0.45.1
openpyxl==2.4.10
osmapi==1.1.0
osmium==2.14.1
overpy==0.4
packaging==16.8
pancritic==0.2
pandas==0.22.0
pandocfilters==1.4.2
panflute==1.10.6
parso==0.1.1
partd==0.3.8
patch==1.16
path.py==10.5
pathlib2==2.3.0
pathtools==0.1.2
patsy==0.5.0
pbr==5.1.1
pdfrw==0.4
pep8==1.7.1
pexpect==4.3.1
pickleshare==0.7.4
Pillow==5.0.0
pipenv==2018.7.1
pkginfo==1.4.1
pluggy==0.6.0
ply==3.10
pre-commit==1.12.0
proboscis==1.2.6.0
prompt-toolkit==1.0.15
protobuf==3.6.1
psutil==5.4.3
ptyprocess==0.5.2
py==1.5.2
pyarrow==0.9.0
pyasn1==0.4.2
pyasn1-modules==0.2.2
pycodestyle==2.3.1
pycosat==0.6.3
pycparser==2.18
pycrypto==2.6.1
pycryptodomex==3.7.0
pycurl==7.43.0.1
pyflakes==1.6.0
PyGithub==1.43.2
Pygments==2.2.0
pyitlib==0.1.13
pyjsparser==2.5.2
PyJWT==1.6.4
pylint==1.8.2
pylzma==0.5.0
pyo365==0.1.3
pyodbc==4.0.22
pyOpenSSL==17.5.0
pypandoc==1.4
pyparsing==2.2.0
pyperclip==1.7.0
Pyphen==0.9.5
PyQt5==5.10.1
PySocks==1.6.7
pyswf==1.5.4
pytest==3.3.2
python-dateutil==2.7.5
python-dotenv==0.8.2
pytz==2018.7
PyWavelets==0.5.2
PyYAML==3.12
pyzmq==16.0.3
QtAwesome==0.4.4
qtconsole==4.3.1
QtPy==1.3.1
requests==2.18.4
requests-ntlm==1.1.0
requests-oauthlib==1.0.0
requests-toolbelt==0.8.0
rope==0.10.7
rsa==4.0
ruamel-yaml==0.15.35
ruamel.yaml==0.15.60
scikit-image==0.13.1
scikit-learn==0.19.1
scipy==1.1.0
seaborn==0.8.1
SecretStorage==2.3.1
semantic-version==2.6.0
Send2Trash==1.4.2
shutilwhich==1.1.0
simplegeneric==0.8.1
singledispatch==3.4.0.3
sip==4.19.8
six==1.11.0
snowballstemmer==1.2.1
sortedcollections==0.5.3
sortedcontainers==1.5.3
Sphinx==1.6.5
sphinxcontrib-websupport==1.0.1
spyder==3.2.6
SQLAlchemy==1.2.1
statsmodels==0.8.0
stringcase==1.2.0
sympy==1.1.1
tables==3.4.2
tblib==1.3.2
terminado==0.8.1
testpath==0.3.1
tinycss2==0.6.1
toml==0.10.0
toolz==0.9.0
tornado==5.1.1
tox==2.9.1
tqdm==4.19.7
traces==0.3.1
traitlets==4.3.2
twine==1.10.0
typing==3.6.2
tzlocal==1.5.1
unicodecsv==0.14.1
urllib3==1.22
validictory==1.1.2
virtualenv==16.0.0
virtualenv-clone==0.3.0
ViTables==3.0.0
vobject==0.9.5
watchdog==0.8.3
wcwidth==0.1.7
WeasyPrint==0.42.3
webencodings==0.5.1
Werkzeug==0.14.1
widgetsnbextension==3.2.1
wrapt==1.10.11
xled==0.5.0
xlrd==1.1.0
XlsxWriter==1.0.2
xlwt==1.3.0
zict==0.1.3
scrool commented 5 years ago

pyzmq==16.0.3

This doesn't match what is required in setup.py - pyzmq>=17.

retorquere commented 5 years ago

when I run python setup.py install I get:

Script started on 2018-12-26 17:52:11+0100
(base) [emile@titanarum xled (develop)]$ python setup.py install
running install
running bdist_egg
running egg_info
writing xled.egg-info/PKG-INFO
writing dependency_links to xled.egg-info/dependency_links.txt
writing entry points to xled.egg-info/entry_points.txt
writing requirements to xled.egg-info/requires.txt
writing top-level names to xled.egg-info/top_level.txt
reading manifest file 'xled.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
warning: no files found matching '*.jpg' under directory 'docs'
warning: no files found matching '*.png' under directory 'docs'
warning: no files found matching '*.gif' under directory 'docs'
writing manifest file 'xled.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/xled
copying build/lib/xled/udp_client.py -> build/bdist.linux-x86_64/egg/xled
copying build/lib/xled/discover.py -> build/bdist.linux-x86_64/egg/xled
copying build/lib/xled/cli.py -> build/bdist.linux-x86_64/egg/xled
copying build/lib/xled/compat.py -> build/bdist.linux-x86_64/egg/xled
copying build/lib/xled/security.py -> build/bdist.linux-x86_64/egg/xled
copying build/lib/xled/auth.py -> build/bdist.linux-x86_64/egg/xled
copying build/lib/xled/exceptions.py -> build/bdist.linux-x86_64/egg/xled
copying build/lib/xled/__version__.py -> build/bdist.linux-x86_64/egg/xled
copying build/lib/xled/util.py -> build/bdist.linux-x86_64/egg/xled
copying build/lib/xled/__init__.py -> build/bdist.linux-x86_64/egg/xled
copying build/lib/xled/control.py -> build/bdist.linux-x86_64/egg/xled
copying build/lib/xled/response.py -> build/bdist.linux-x86_64/egg/xled
byte-compiling build/bdist.linux-x86_64/egg/xled/udp_client.py to udp_client.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/xled/discover.py to discover.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/xled/cli.py to cli.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/xled/compat.py to compat.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/xled/security.py to security.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/xled/auth.py to auth.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/xled/exceptions.py to exceptions.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/xled/__version__.py to __version__.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/xled/util.py to util.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/xled/__init__.py to __init__.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/xled/control.py to control.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/xled/response.py to response.cpython-36.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying xled.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xled.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xled.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xled.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xled.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xled.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying xled.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
creating 'dist/xled-0.5.0-py3.6.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing xled-0.5.0-py3.6.egg
removing '/home/emile/anaconda3/lib/python3.6/site-packages/xled-0.5.0-py3.6.egg' (and everything under it)
creating /home/emile/anaconda3/lib/python3.6/site-packages/xled-0.5.0-py3.6.egg
Extracting xled-0.5.0-py3.6.egg to /home/emile/anaconda3/lib/python3.6/site-packages
xled 0.5.0 is already the active version in easy-install.pth
Installing xled script to /home/emile/anaconda3/bin

Installed /home/emile/anaconda3/lib/python3.6/site-packages/xled-0.5.0-py3.6.egg
Processing dependencies for xled==0.5.0
Searching for requests-toolbelt==0.8.0
Best match: requests-toolbelt 0.8.0
Adding requests-toolbelt 0.8.0 to easy-install.pth file

Using /home/emile/anaconda3/lib/python3.6/site-packages
Searching for tornado==5.1.1
Best match: tornado 5.1.1
Adding tornado 5.1.1 to easy-install.pth file

Using /home/emile/anaconda3/lib/python3.6/site-packages
Searching for requests==2.18.4
Best match: requests 2.18.4
Adding requests 2.18.4 to easy-install.pth file

Using /home/emile/anaconda3/lib/python3.6/site-packages
Searching for pyzmq==17.1.2
Best match: pyzmq 17.1.2
Processing pyzmq-17.1.2-py3.6-linux-x86_64.egg
pyzmq 17.1.2 is already the active version in easy-install.pth

Using /home/emile/anaconda3/lib/python3.6/site-packages/pyzmq-17.1.2-py3.6-linux-x86_64.egg
Searching for netaddr==0.7.19
Best match: netaddr 0.7.19
Processing netaddr-0.7.19-py3.6.egg
netaddr 0.7.19 is already the active version in easy-install.pth
Installing netaddr script to /home/emile/anaconda3/bin

Using /home/emile/anaconda3/lib/python3.6/site-packages/netaddr-0.7.19-py3.6.egg
Searching for cryptography==2.1.4
Best match: cryptography 2.1.4
Adding cryptography 2.1.4 to easy-install.pth file

Using /home/emile/anaconda3/lib/python3.6/site-packages
Searching for click==6.7
Best match: click 6.7
Adding click 6.7 to easy-install.pth file

Using /home/emile/anaconda3/lib/python3.6/site-packages
Searching for click-log==0.3.2
Best match: click-log 0.3.2
Processing click_log-0.3.2-py3.6.egg
click-log 0.3.2 is already the active version in easy-install.pth

Using /home/emile/anaconda3/lib/python3.6/site-packages/click_log-0.3.2-py3.6.egg
Searching for arpreq==0.3.3
Best match: arpreq 0.3.3
Processing arpreq-0.3.3-py3.6-linux-x86_64.egg
arpreq 0.3.3 is already the active version in easy-install.pth

Using /home/emile/anaconda3/lib/python3.6/site-packages/arpreq-0.3.3-py3.6-linux-x86_64.egg
Searching for certifi==2018.10.15
Best match: certifi 2018.10.15
Adding certifi 2018.10.15 to easy-install.pth file

Using /home/emile/anaconda3/lib/python3.6/site-packages
Searching for urllib3==1.22
Best match: urllib3 1.22
Adding urllib3 1.22 to easy-install.pth file

Using /home/emile/anaconda3/lib/python3.6/site-packages
Searching for idna==2.6
Best match: idna 2.6
Adding idna 2.6 to easy-install.pth file

Using /home/emile/anaconda3/lib/python3.6/site-packages
Searching for chardet==3.0.4
Best match: chardet 3.0.4
Adding chardet 3.0.4 to easy-install.pth file
Installing chardetect script to /home/emile/anaconda3/bin

Using /home/emile/anaconda3/lib/python3.6/site-packages
Searching for cffi==1.11.4
Best match: cffi 1.11.4
Adding cffi 1.11.4 to easy-install.pth file

Using /home/emile/anaconda3/lib/python3.6/site-packages
Searching for six==1.11.0
Best match: six 1.11.0
Adding six 1.11.0 to easy-install.pth file

Using /home/emile/anaconda3/lib/python3.6/site-packages
Searching for asn1crypto==0.24.0
Best match: asn1crypto 0.24.0
Adding asn1crypto 0.24.0 to easy-install.pth file

Using /home/emile/anaconda3/lib/python3.6/site-packages
Searching for pycparser==2.18
Best match: pycparser 2.18
Adding pycparser 2.18 to easy-install.pth file

Using /home/emile/anaconda3/lib/python3.6/site-packages
Finished processing dependencies for xled==0.5.0
(base) [emile@titanarum xled (develop)]$ exit

Script done on 2018-12-26 17:52:18+0100
scrool commented 5 years ago

What operating system and version are you running that on?

retorquere commented 5 years ago

Linux

scrool commented 5 years ago

Distribution and version?

retorquere commented 5 years ago

Ubuntu 18.04, but python is installed using anaconda.

retorquere commented 5 years ago

Running pip uninstall pyzmq and then re-running python setup.py install fixed the issue

scrool commented 5 years ago

Amazing!