erijo / tellcore-py

Python wrapper for Telldus' home automation library Telldus Core
GNU General Public License v3.0
44 stars 6 forks source link

Can't run on Mac OS X #3

Closed pkempe closed 10 years ago

pkempe commented 10 years ago

Building and installing and works on Mac OS X 10.9, but when trying to invoke the example script td_list_controllers I get the following output:

patrik@iceman:/Volumes/home/tellcore-py-master/bin$ python td_list_controllers 
Traceback (most recent call last):
  File "td_list_controllers", line 8, in <module>
    core = td.TelldusCore()
  File "/Library/Python/2.7/site-packages/tellcore/telldus.py", line 57, in __init__
    self.lib = Library()
  File "/Library/Python/2.7/site-packages/tellcore/library.py", line 305, in __init__
    lib = DllLoader.LoadLibrary(name)
  File     "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
    return self._dlltype(name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libtelldus-core.so.2, 6): image not found

I have TelldusCenter 2.1.2beta installed, and can run tdtool just fine.

erijo commented 10 years ago

Can you try changing the line "core = td.TelldusCore()" in td_list_controllers.py to core = td.TelldusCore('TelldusCore')

If that doesn't work, try this instead: core = td.TelldusCore('/Library/Frameworks/TelldusCore.framework/TelldusCore')

pkempe commented 10 years ago

The first one makes no difference, but the latter gets around the dlopen errors at least. The script runs a bit farther, but there's another error coming:

patrik@iceman:/Volumes/home/tellcore-py-master/bin$ python td_list_controllers 
Traceback (most recent call last):
  File "td_list_controllers", line 25, in <module>
    TYPES[controller.type], controller.name, controller.serial,
  File "/Library/Python/2.7/site-packages/tellcore/telldus.py", line 349, in __getattr__
    raise AttributeError(name)
AttributeError: name
pkempe commented 10 years ago

As a side note, changing the corresponding lines in td_sensors and td_event_tracer makes them work without errors.

erijo commented 10 years ago

Thanks for testing.

I will update the code to use that library on mac os x by default. Then I will fix the script to handle controllers without a name set.

erijo commented 10 years ago

Could you please also test if it works with /TelldusCore.framework/TelldusCore ?

pkempe commented 10 years ago

Tried swapping line

core = td.TelldusCore('/Library/Frameworks/TelldusCore.framework/TelldusCore')

for

core = td.TelldusCore('/TelldusCore.framework/TelldusCore')

with the following results:

patrik@iceman:/Volumes/home/tellcore-py-master/bin$ python td_event_tracer 
Traceback (most recent call last):
  File "td_event_tracer", line 93, in <module>
    core = td.TelldusCore('/TelldusCore.framework/TelldusCore')
  File "/Library/Python/2.7/site-packages/tellcore/telldus.py", line 55, in __init__
    self.lib = Library(library_path)
  File "/Library/Python/2.7/site-packages/tellcore/library.py", line 305, in __init__
    lib = DllLoader.LoadLibrary(name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 443 in LoadLibrary
    return self._dlltype(name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/TelldusCore.framework/TelldusCore, 6): image not found
erijo commented 10 years ago

Please try pulling the latest changes and see if it works now.

pkempe commented 10 years ago

The framework loading bit still fails (the error message is the same as before):

OSError: dlopen(libtelldus-core.so.2, 6): image not found

but the unnamed controller stuff is OK. After manually changing the line in td_list_controllers to what worked in your previous suggestion (core = td.TelldusCore('/Library/Frameworks/TelldusCore.framework/TelldusCore') I get proper output.

erijo commented 10 years ago

What output does this command give: python -c 'import platform; print platform.system()'

pkempe commented 10 years ago
patrik@iceman:/Volumes/home/tellcore-py/bin$ python -c 'import platform; print platform.system()'
Darwin
erijo commented 10 years ago

What about: python -c 'import tellcore.library; print tellcore.library.LIBRARY_NAME'

pkempe commented 10 years ago
patrik@iceman:/Volumes/home/tellcore-py/bin$ python -c 'import tellcore.library; print tellcore.library.LIBRARY_NAME'
libtelldus-core.so.2
erijo commented 10 years ago

And this: python -c 'import tellcore.library; print tellcore.library'

pkempe commented 10 years ago
patrik@iceman:/Volumes/home/tellcore-py/bin$ python -c 'import tellcore.library; print tellcore.library'
<module 'tellcore.library' from '/Library/Python/2.7/site-packages/tellcore/library.pyc'>
erijo commented 10 years ago

What if you run: PYTHONPATH=Volumes/home/tellcore-py python -c 'import tellcore.library; print tellcore.library.LIBRARY_NAME'

pkempe commented 10 years ago
patrik@iceman:/Volumes/home/tellcore-py/bin$ PYTHONPATH=Volumes/home/tellcore-py python -c 'import tellcore.library; print tellcore.library.LIBRARY_NAME'
libtelldus-core.so.2
erijo commented 10 years ago

I missed the first / in PYTHONPATH, it should have been: PYTHONPATH=/Volumes/home/tellcore-py python -c 'import tellcore.library; print tellcore.library.LIBRARY_NAME'

pkempe commented 10 years ago
patrik@iceman:/Volumes/home/tellcore-py/bin$ PYTHONPATH=/Volumes/home/tellcore-py python -c 'import tellcore.library; print tellcore.library.LIBRARY_NAME'
/Library/Frameworks/TelldusCore.framework/TelldusCore
erijo commented 10 years ago

This should work then: PYTHONPATH=/Volumes/home/tellcore-py ./td_list_controllers

Looks like you have an older version installed. Could that be right?

pkempe commented 10 years ago

Ouch, very sorry. I just pulled the latest version from the repo and forgot to build and install. It all works now...

erijo commented 10 years ago

Perfect. Thanks for reporting and testing!

pkempe commented 10 years ago

You're welcome!