Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect error when driver runtime not installed #1970

Closed
marcoskirsch opened this issue May 31, 2023 · 0 comments · Fixed by #1992
Closed

Incorrect error when driver runtime not installed #1970

marcoskirsch opened this issue May 31, 2023 · 0 comments · Fixed by #1992

Comments

@marcoskirsch
Copy link
Member

Description of issue

I wrote a simple Python script that uses niswitch but forgot to install the NI-SWITCH driver runtime.
I got the following error:

C:\Users\mkirsch>python ceip_test.py
Traceback (most recent call last):
  File "C:\Users\mkirsch\ceip_test.py", line 44, in <module>
    with niswitch.Session(resource_name="2510") as s:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mkirsch\AppData\Local\Programs\Python\Python311\Lib\site-packages\niswitch\session.py", line 1362, in __init__
    interpreter = _library_interpreter.LibraryInterpreter(encoding='windows-1251')
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mkirsch\AppData\Local\Programs\Python\Python311\Lib\site-packages\niswitch\_library_interpreter.py", line 58, in __init__
    self._library = _library_singleton.get()
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mkirsch\AppData\Local\Programs\Python\Python311\Lib\site-packages\niswitch\_library_singleton.py", line 50, in get
    ctypes_library = ctypes.CDLL(_get_library_name())
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mkirsch\AppData\Local\Programs\Python\Python311\Lib\ctypes\__init__.py", line 366, in __init__
    if '/' in name or '\\' in name:
       ^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

I expected DriverNotInstalledError

It's not good if we broke this and our automated testing (unit testing in this case) didn't catch it.

System report

C:\Users\mkirsch>python -c "import niswitch; niswitch.print_diagnostic_information()"
OS:
    Name:      Windows
    Version:   10.0.22000
    Bits:      64
Driver:
    Name:      NI-SWITCH
    Version:   Unknown
Module:
    Name:      niswitch
    Version:   1.4.4
Python:
    Version:   3.11.3 (tags/v3.11.3:f3909b8, Apr  4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)]
    Bits:      64
    Is_Venv:   False
    Installed Packages:
        setuptools==65.5.0
        pip==22.3.1
        nidcpower==1.4.4
        nidmm==1.4.4
        niswitch==1.4.4
        hightime==0.2.1

Steps to reproduce issue

On a system in which NI-SWITCH driver runtime is not installed, run the following script:

import niswitch

with niswitch.Session(resource_name="2510") as s:
    pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant