Skip to content

This library crashes when imported #14

@cnobile2012

Description

@cnobile2012

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.

  1. Error: RTk.GPIO not detected. This is confusing since it can be confused for either the API path or the hardware.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions