You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Python 3.8.10. I get the following traceback.
In [1]: from RTk import GPIO
Error: RTk.GPIO not detected.
For more support please visit our website at http://Ryanteck.com/rtk-000-00C
Press enter to close.
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 from RTk import GPIO
File ~/.virtualenvs/RTk_Test/lib/python3.8/site-packages/RTk/GPIO.py:54, in <module>
43 from RTk import adaptors
46 #from os import sys, path
47 #thisdir = path.dirname(path.abspath(__file__))
48 #sys.path.append(thisdir)
(...)
51
52 #Temporarily changing back to normal serial
---> 54 from RTk import rtkserial
56 instance = protocol.GPIOClient(adaptors.SerialAdaptor(rtkserial.s), DEBUG)
58 def setwarnings(option):
File ~/.virtualenvs/RTk_Test/lib/python3.8/site-packages/RTk/rtkserial.py:36, in <module>
34 print ("\nError: RTk.GPIO not detected.\nFor more support please visit our website at http://Ryanteck.com/rtk-000-00C\nPress enter to close.")
35 input()
---> 36 exit()
38 #print ("Debug cable fully detected fine.\n Press enter to launch the terminal.")
41 BAUD = 230400
NameError: name 'exit' is not defined
There are two issues in that traceback.
Error: RTk.GPIO not detected. This is confusing since it can be confused for either the API path or the hardware.
The exit() function is not found. This is correct there is NO built-in function named exit(). It's in the sys package. I doubt this function is even needed since it would only be needed in a script run on the command line. This is a library, not a script. Add an else after the if(rtkGPIOPort == ""): and put everything after that in the else, then removing the exit() will just fall through and do nothing. Then in the RTk/GPIO.py file put a try/except AttributeError block around the instance = protocol.GPIOClient(adaptors.SerialAdaptor(rtkserial.s), DEBUG) statement and put everything else in an else clause.
I also found that there are tabs used in the code which go against PEP8 the Python programming style guide.
I've been developing python code for over 20 years, so I know these are real issues.
The text was updated successfully, but these errors were encountered:
How did you install the library? Using the install via setup.py does not work (Probably a victim when the Ryanteck code was moved to PiSupply).
I just tried with pip on my Mac (python 3.9.1 from homebrew) and it works fine.
No import error.
Regarding exit(). Yes, it is not recommended, better to take your proposed approach.
I am not the maintainer for the Ryanteck code, nor working for PiSupply, hence I cannot guarantee that it will be fixed.
What I did was to copy the code from the pip install and fix the code myself, expecting that the code will never be maintained even in the newer Bitbucket repo. I may eventually push my fixes to my GitHub account if I decide to do anything other than a few bug fixes. There is little support for a lot of features the board can do, but the software cannot do.
I often find that hardware people are not good at writing good professional code with proper unit testing, this is another example of that problem.
I'm using Python 3.8.10. I get the following traceback.
There are two issues in that traceback.
sys
package. I doubt this function is even needed since it would only be needed in a script run on the command line. This is a library, not a script. Add anelse
after theif(rtkGPIOPort == ""):
and put everything after that in theelse
, then removing the exit() will just fall through and do nothing. Then in theRTk/GPIO.py
file put atry/except AttributeError
block around theinstance = protocol.GPIOClient(adaptors.SerialAdaptor(rtkserial.s), DEBUG)
statement and put everything else in anelse
clause.I also found that there are tabs used in the code which go against PEP8 the Python programming style guide.
I've been developing python code for over 20 years, so I know these are real issues.
The text was updated successfully, but these errors were encountered: