ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
426 stars 145 forks source link

ButtonEVIO references _file_cache #167

Closed dwalton76 closed 7 years ago

dwalton76 commented 8 years ago

File "./rubiks.py", line 47, in init self.buttons = Button() File "build/bdist.linux-armv5tejl/egg/ev3dev/core.py", line 2118, in init File "build/bdist.linux-armv5tejl/egg/ev3dev/core.py", line 2122, in _button_file

dwalton76 commented 8 years ago

@rhempel if you can point me in the right direction on how this should work I can look at this one

rhempel commented 8 years ago

Is this using the latest (untagged) version of the binding in the develop branch?

dwalton76 commented 8 years ago

yes

rhempel commented 8 years ago

OK, I'll look at adding a Button() unit test set (I need to do this anyways, and figure out what's going on. I think that somewhere around 2118 and 2112 is where to start looking :-)

Most likely the issue is the way the Button instance is instatiated - and as I recall that part of the binding is hand-generated.

ddemidov commented 8 years ago

Looks like the problem was introduced in #162. The Button class is derived from Device and uses _file_cache which was removed in #162.

rhempel commented 8 years ago

Hmmm, I thought I had removed all the uses of _file_cache - either I did not or I clobbered a merge somewhere. Either way, a test suite for Buttons() is next in line to get done, and then fixing the code should allow the tests to pass,

rhempel commented 8 years ago

Unit test case created and failing (good) - code fix should arrive tomorrow ... I certainly removed the first instance of the _file_cache but did not complete the task

rhempel commented 8 years ago

I finally got this done - the current https://github.com/rhempel/ev3dev-lang-python/tree/develop branch has the most up to date code - feel free to test and provide feedback

Kurtoid commented 8 years ago

Newbie here: how can I apply the fix to my brick?

rhempel commented 8 years ago

Thanks for checking to see if this is an existing issue :-) If you are comfortable with the command line and you are using Python2, you can replace the file at /usr/lib/python2.7/dist-packages/ev3dev/ev3.py with the one from the current https://github.com/rhempel/ev3dev-lang-python/tree/develop branch. If you're using Python3 - it's more complicated and you have to fix a .egg file.

I am working on fixing a few things in the Python API (still) and plan to release something soon (can't be more specific than that - sorry)

Kurtoid commented 8 years ago

If egg files are a zip file, can i just unzip it, change the code and zip it again? (python3) Thanks

rhempel commented 8 years ago

I think so - or you can do what I did which is rename the egg file to some other extension and link the Python 3 library folder to the Python 2 library

But I was not sure how comfortable you were doing any of this :-)

Kurtoid commented 8 years ago

Thanks! I deleted the python 3 egg file, and copied the python 2 version to 3, and then patched the file.

dwalton76 commented 8 years ago

sudo python setup.py install

Is worth a try