pylablib.devices.utils package

Submodules

pylablib.devices.utils.load_lib module

pylablib.devices.utils.load_lib.get_os_lib_folder()[source]

Get default Windows DLL folder (System32 or SysWOW64, depending on Python and Windows bitness)

pylablib.devices.utils.load_lib.get_program_files_folder(subfolder='', arch=None)[source]

Get default Windows Program Files folder or a subfolder within it.

If arch is None, use the current Python architecture to determine the folder; otherwise, it specifies the architecture ("32bit" for Program Files (x86), "64bit" for Program Files)

pylablib.devices.utils.load_lib.load_lib(name, locations=('global', ), call_conv='cdecl', locally=False, depends=None, depends_required=True, error_message=None, check_order='location', return_location=False)[source]

Load DLL.

Parameters:
  • name – name or path of the library (can also be a list or a tuple with several names, which are tried in that order).
  • locations – list or tuple of locations to search for a library; the function tries locations in order and returns the first successfully loaded library a location is a string which can be a path to the containing folder, "parameter/*" (the remaining part is a subpath inside "devices/dlls" library parameters; if this parameter is defined, it names folder or file for the dll), or "global" (load path as is; also searches in the standard OS specified locations determined by PATH variable, e.g., System32 folder).
  • depends – if specified, it is a list of dependency libraries which need to be loaded first before the main DLL; they are assumed to be in the same location as the main file
  • depends_required – if False, ignore errors during dependency loads
  • locally (bool) – if True, prepend path to the DLL containing folder to the environment PATH folders; this is usually required, if the loaded DLL imports other DLLs in the same folder
  • call_conv (str) – DLL call convention; can be either "cdecl" (corresponds to ctypes.cdll) or "stdcall" (corresponds to ctypes.windll)
  • error_message (str) – error message to add in addition to the default error message shown when the DLL is not found
  • check_order (str) – determines the order in which possible combinations of names and locations are looped over; can be "location" (loop over locations, and for each location loop over names), "name" (loop over names, and for each name loop over locations), or a list of tuples [(loc,name)] specifying order of checking (in the latter case, name and location arguments are ignored, except for generating error message).
  • return_location (bool) – if True, return a tuple (dll, location, folder) instead of a single dll.
class pylablib.devices.utils.load_lib.TLibraryOpenResult(init_result, open_result, opid)

Bases: tuple

count()

Return number of occurrences of value.

index()

Return first index of value.

Raises ValueError if the value is not present.

init_result
open_result
opid
class pylablib.devices.utils.load_lib.TLibraryCloseResult(close_result, uninit_result)

Bases: tuple

close_result
count()

Return number of occurrences of value.

index()

Return first index of value.

Raises ValueError if the value is not present.

uninit_result
class pylablib.devices.utils.load_lib.LibraryController(lib)[source]

Bases: object

Simple wrapper to control libraries which require initialization when a new device is opened or shutdown when all devices are closed.

Parameters:lib – controlled library
preinit()[source]

Pre-initialize the library, if it hasn’t been done already

open()[source]

Mark device opening.

Return tuple (init_result, open_result, opid) with the results of the initialization and the opening, and the opening ID which should afterwards be used for closing. If library is already initialized, set init_result=None

close(opid)[source]

Mark device closing.

Return tuple (close_result, uninit_result) with the results of the closing and the shutdown. If library does not need to be shut down yet, set uninit_result=None

temp_open()[source]

Context for temporarily opening a new device connection

shutdown()[source]

Close all opened connections and shutdown the library

Module contents