INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Moves an 8-bit block of data from local memory to the specified address space and offset.
Corresponds to viMoveOut8* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param space: Specifies the address space. (Co... | def move_out_8(library, session, space, offset, length, data, extended=False):
"""Moves an 8-bit block of data from local memory to the specified address space and offset.
Corresponds to viMoveOut8* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Uniq... |
Moves an 16-bit block of data from local memory to the specified address space and offset.
Corresponds to viMoveOut16* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param space: Specifies the address space. (... | def move_out_16(library, session, space, offset, length, data, extended=False):
"""Moves an 16-bit block of data from local memory to the specified address space and offset.
Corresponds to viMoveOut16* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: U... |
Moves an 64-bit block of data from local memory to the specified address space and offset.
Corresponds to viMoveOut64* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param space: Specifies the address space. (... | def move_out_64(library, session, space, offset, length, data, extended=False):
"""Moves an 64-bit block of data from local memory to the specified address space and offset.
Corresponds to viMoveOut64* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: U... |
Moves an 32-bit block of data from local memory to the specified address space and offset.
Corresponds to viMoveOut32* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param space: Specifies the address space. (... | def move_out_32(library, session, space, offset, length, data, extended=False):
"""Moves an 32-bit block of data from local memory to the specified address space and offset.
Corresponds to viMoveOut32* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: U... |
Opens a session to the specified resource.
Corresponds to viOpen function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Resource Manager session (should always be a session returned from open_default_resource_manager()).
:param resource_name: Unique symbolic ... | def open(library, session, resource_name,
access_mode=constants.AccessModes.no_lock, open_timeout=constants.VI_TMO_IMMEDIATE):
"""Opens a session to the specified resource.
Corresponds to viOpen function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: ... |
This function returns a session to the Default Resource Manager resource.
Corresponds to viOpenDefaultRM function of the VISA library.
:param library: the visa library wrapped by ctypes.
:return: Unique logical identifier to a Default Resource Manager session, return value of the library call.
:rtype:... | def open_default_resource_manager(library):
"""This function returns a session to the Default Resource Manager resource.
Corresponds to viOpenDefaultRM function of the VISA library.
:param library: the visa library wrapped by ctypes.
:return: Unique logical identifier to a Default Resource Manager ses... |
Write in an 8-bit, 16-bit, 32-bit, value to the specified memory space and offset.
Corresponds to viOut* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param space: Specifies the address space. (Constants.*SPA... | def write_memory(library, session, space, offset, data, width, extended=False):
"""Write in an 8-bit, 16-bit, 32-bit, value to the specified memory space and offset.
Corresponds to viOut* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical ... |
Write in an 8-bit value from the specified memory space and offset.
Corresponds to viOut8* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param space: Specifies the address space. (Constants.*SPACE*)
:para... | def out_8(library, session, space, offset, data, extended=False):
"""Write in an 8-bit value from the specified memory space and offset.
Corresponds to viOut8* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
... |
Write in an 16-bit value from the specified memory space and offset.
Corresponds to viOut16* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param space: Specifies the address space. (Constants.*SPACE*)
:pa... | def out_16(library, session, space, offset, data, extended=False):
"""Write in an 16-bit value from the specified memory space and offset.
Corresponds to viOut16* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
... |
Write in an 32-bit value from the specified memory space and offset.
Corresponds to viOut32* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param space: Specifies the address space. (Constants.*SPACE*)
:pa... | def out_32(library, session, space, offset, data, extended=False):
"""Write in an 32-bit value from the specified memory space and offset.
Corresponds to viOut32* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
... |
Write in an 64-bit value from the specified memory space and offset.
Corresponds to viOut64* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param space: Specifies the address space. (Constants.*SPACE*)
:pa... | def out_64(library, session, space, offset, data, extended=False):
"""Write in an 64-bit value from the specified memory space and offset.
Corresponds to viOut64* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
... |
Parse a resource string to get the interface information.
Corresponds to viParseRsrc function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Resource Manager session (should always be the Default Resource Manager for VISA
returned from open_def... | def parse_resource(library, session, resource_name):
"""Parse a resource string to get the interface information.
Corresponds to viParseRsrc function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Resource Manager session (should always be the Default Resource... |
Parse a resource string to get extended interface information.
Corresponds to viParseRsrcEx function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Resource Manager session (should always be the Default Resource Manager for VISA
returned from o... | def parse_resource_extended(library, session, resource_name):
"""Parse a resource string to get extended interface information.
Corresponds to viParseRsrcEx function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Resource Manager session (should always be the ... |
Read an 8, 16 or 32-bit value from the specified address.
Corresponds to viPeek* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:param width: Number of bits... | def peek(library, session, address, width):
"""Read an 8, 16 or 32-bit value from the specified address.
Corresponds to viPeek* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address ... |
Read an 8-bit value from the specified address.
Corresponds to viPeek8 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:return: Data read from bus, return val... | def peek_8(library, session, address):
"""Read an 8-bit value from the specified address.
Corresponds to viPeek8 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the valu... |
Read an 16-bit value from the specified address.
Corresponds to viPeek16 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:return: Data read from bus, return v... | def peek_16(library, session, address):
"""Read an 16-bit value from the specified address.
Corresponds to viPeek16 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the v... |
Read an 32-bit value from the specified address.
Corresponds to viPeek32 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:return: Data read from bus, return v... | def peek_32(library, session, address):
"""Read an 32-bit value from the specified address.
Corresponds to viPeek32 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the v... |
Read an 64-bit value from the specified address.
Corresponds to viPeek64 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:return: Data read from bus, return v... | def peek_64(library, session, address):
"""Read an 64-bit value from the specified address.
Corresponds to viPeek64 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the v... |
Writes an 8, 16 or 32-bit value from the specified address.
Corresponds to viPoke* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:param width: Number of bi... | def poke(library, session, address, width, data):
"""Writes an 8, 16 or 32-bit value from the specified address.
Corresponds to viPoke* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source ... |
Write an 8-bit value from the specified address.
Corresponds to viPoke8 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:param data: value to be written to th... | def poke_8(library, session, address, data):
"""Write an 8-bit value from the specified address.
Corresponds to viPoke8 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read t... |
Write an 16-bit value from the specified address.
Corresponds to viPoke16 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:param data: value to be written to ... | def poke_16(library, session, address, data):
"""Write an 16-bit value from the specified address.
Corresponds to viPoke16 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to rea... |
Write an 32-bit value from the specified address.
Corresponds to viPoke32 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:param data: value to be written to ... | def poke_32(library, session, address, data):
"""Write an 32-bit value from the specified address.
Corresponds to viPoke32 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to rea... |
Write an 64-bit value from the specified address.
Corresponds to viPoke64 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:param data: value to be written to ... | def poke_64(library, session, address, data):
"""Write an 64-bit value from the specified address.
Corresponds to viPoke64 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to rea... |
Reads data from device or interface synchronously.
Corresponds to viRead function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param count: Number of bytes to be read.
:return: data read, return value of the libra... | def read(library, session, count):
"""Reads data from device or interface synchronously.
Corresponds to viRead function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param count: Number of bytes to be read.
:re... |
Reads data from device or interface asynchronously.
Corresponds to viReadAsync function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param count: Number of bytes to be read.
:return: result, jobid, return value of... | def read_asynchronously(library, session, count):
"""Reads data from device or interface asynchronously.
Corresponds to viReadAsync function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param count: Number of byte... |
Reads a status byte of the service request.
Corresponds to viReadSTB function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:return: Service request status byte, return value of the library call.
:rtype: int, :class... | def read_stb(library, session):
"""Reads a status byte of the service request.
Corresponds to viReadSTB function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:return: Service request status byte, return value of th... |
Read data synchronously, and store the transferred data in a file.
Corresponds to viReadToFile function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param filename: Name of file to which data will be written.
:par... | def read_to_file(library, session, filename, count):
"""Read data synchronously, and store the transferred data in a file.
Corresponds to viReadToFile function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param fi... |
Sets the state of an attribute.
Corresponds to viSetAttribute function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param attribute: Attribute for which the state is to be modified. (Attributes.*)
:param attribute... | def set_attribute(library, session, attribute, attribute_state):
"""Sets the state of an attribute.
Corresponds to viSetAttribute function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param attribute: Attribute fo... |
Sets the size for the formatted I/O and/or low-level I/O communication buffer(s).
Corresponds to viSetBuf function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param mask: Specifies the type of buffer. (Constants.READ... | def set_buffer(library, session, mask, size):
"""Sets the size for the formatted I/O and/or low-level I/O communication buffer(s).
Corresponds to viSetBuf function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:para... |
Returns a user-readable description of the status code passed to the operation.
Corresponds to viStatusDesc function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param status: Status code to interpret.
:return: - ... | def status_description(library, session, status):
"""Returns a user-readable description of the status code passed to the operation.
Corresponds to viStatusDesc function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
... |
Requests a VISA session to terminate normal execution of an operation.
Corresponds to viTerminate function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param degree: Constants.NULL
:param job_id: Specifies an oper... | def terminate(library, session, degree, job_id):
"""Requests a VISA session to terminate normal execution of an operation.
Corresponds to viTerminate function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param deg... |
Uninstalls handlers for events.
Corresponds to viUninstallHandler function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param event_type: Logical event identifier.
:param handler: Interpreted as a valid reference ... | def uninstall_handler(library, session, event_type, handler, user_handle=None):
"""Uninstalls handlers for events.
Corresponds to viUninstallHandler function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param even... |
Undo a previous map from the specified trigger source line to the specified destination line.
Corresponds to viUnmapTrigger function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param trigger_source: Source line used ... | def unmap_trigger(library, session, trigger_source, trigger_destination):
"""Undo a previous map from the specified trigger source line to the specified destination line.
Corresponds to viUnmapTrigger function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Uni... |
Performs a USB control pipe transfer from the device.
Corresponds to viUsbControlIn function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param request_type_bitmap_field: bmRequestType parameter of the setup stage of ... | def usb_control_in(library, session, request_type_bitmap_field, request_id, request_value,
index, length=0):
"""Performs a USB control pipe transfer from the device.
Corresponds to viUsbControlIn function of the VISA library.
:param library: the visa library wrapped by ctypes.
:para... |
Performs a USB control pipe transfer to the device.
Corresponds to viUsbControlOut function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param request_type_bitmap_field: bmRequestType parameter of the setup stage of a... | def usb_control_out(library, session, request_type_bitmap_field, request_id, request_value,
index, data=""):
"""Performs a USB control pipe transfer to the device.
Corresponds to viUsbControlOut function of the VISA library.
:param library: the visa library wrapped by ctypes.
:para... |
Sends the device a miscellaneous command or query and/or retrieves the response to a previous query.
Corresponds to viVxiCommandQuery function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param mode: Specifies whether... | def vxi_command_query(library, session, mode, command):
"""Sends the device a miscellaneous command or query and/or retrieves the response to a previous query.
Corresponds to viVxiCommandQuery function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logi... |
Waits for an occurrence of the specified event for a given session.
Corresponds to viWaitOnEvent function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param in_event_type: Logical identifier of the event(s) to wait fo... | def wait_on_event(library, session, in_event_type, timeout):
"""Waits for an occurrence of the specified event for a given session.
Corresponds to viWaitOnEvent function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
... |
Writes data to device or interface synchronously.
Corresponds to viWrite function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param data: data to be written.
:type data: str
:return: Number of bytes actually ... | def write(library, session, data):
"""Writes data to device or interface synchronously.
Corresponds to viWrite function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param data: data to be written.
:type data: ... |
Writes data to device or interface asynchronously.
Corresponds to viWriteAsync function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param data: data to be written.
:return: Job ID of this asynchronous write opera... | def write_asynchronously(library, session, data):
"""Writes data to device or interface asynchronously.
Corresponds to viWriteAsync function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param data: data to be writ... |
Take data from a file and write it out synchronously.
Corresponds to viWriteFromFile function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param filename: Name of file from which data will be read.
:param count: N... | def write_from_file(library, session, filename, count):
"""Take data from a file and write it out synchronously.
Corresponds to viWriteFromFile function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param filename:... |
Reads in an 8-bit, 16-bit, 32-bit, or 64-bit value from the specified memory space and offset.
:param space: Specifies the address space. (Constants.*SPACE*)
:param offset: Offset (in bytes) of the address or register from which to read.
:param width: Number of bits to read.
:param exte... | def read_memory(self, space, offset, width, extended=False):
"""Reads in an 8-bit, 16-bit, 32-bit, or 64-bit value from the specified memory space and offset.
:param space: Specifies the address space. (Constants.*SPACE*)
:param offset: Offset (in bytes) of the address or register from which to... |
Write in an 8-bit, 16-bit, 32-bit, value to the specified memory space and offset.
:param space: Specifies the address space. (Constants.*SPACE*)
:param offset: Offset (in bytes) of the address or register from which to read.
:param data: Data to write to bus.
:param width: Number of bi... | def write_memory(self, space, offset, data, width, extended=False):
"""Write in an 8-bit, 16-bit, 32-bit, value to the specified memory space and offset.
:param space: Specifies the address space. (Constants.*SPACE*)
:param offset: Offset (in bytes) of the address or register from which to read... |
Moves a block of data to local memory from the specified address space and offset.
:param space: Specifies the address space. (Constants.*SPACE*)
:param offset: Offset (in bytes) of the address or register from which to read.
:param length: Number of elements to transfer, where the data width o... | def move_in(self, space, offset, length, width, extended=False):
"""Moves a block of data to local memory from the specified address space and offset.
:param space: Specifies the address space. (Constants.*SPACE*)
:param offset: Offset (in bytes) of the address or register from which to read.
... |
Moves a block of data from local memory to the specified address space and offset.
:param space: Specifies the address space. (Constants.*SPACE*)
:param offset: Offset (in bytes) of the address or register from which to read.
:param length: Number of elements to transfer, where the data width o... | def move_out(self, space, offset, length, data, width, extended=False):
"""Moves a block of data from local memory to the specified address space and offset.
:param space: Specifies the address space. (Constants.*SPACE*)
:param offset: Offset (in bytes) of the address or register from which to ... |
Returns True if the attribute is part of a given session type.
The session_type is a tuple with the interface type and resource_class
:type session_type: (constants.InterfaceType, str)
:rtype: bool | def in_resource(cls, session_type):
"""Returns True if the attribute is part of a given session type.
The session_type is a tuple with the interface type and resource_class
:type session_type: (constants.InterfaceType, str)
:rtype: bool
"""
if cls.resources is AllSessio... |
List all connected resources. | def do_list(self, args):
"""List all connected resources."""
try:
resources = self.resource_manager.list_resources_info()
except Exception as e:
print(e)
else:
self.resources = []
for ndx, (resource_name, value) in enumerate(resources.item... |
Open resource by number, resource name or alias: open 3 | def do_open(self, args):
"""Open resource by number, resource name or alias: open 3"""
if not args:
print('A resource name must be specified.')
return
if self.current:
print('You can only open one resource at a time. Please close the current one first.')
... |
Close resource in use. | def do_close(self, args):
"""Close resource in use."""
if not self.current:
print('There are no resources in use. Use the command "open".')
return
try:
self.current.close()
except Exception as e:
print(e)
else:
print('... |
Query resource in use: query *IDN? | def do_query(self, args):
"""Query resource in use: query *IDN? """
if not self.current:
print('There are no resources in use. Use the command "open".')
return
try:
print('Response: {}'.format(self.current.query(args)))
except Exception as e:
... |
Receive from the resource in use. | def do_read(self, args):
"""Receive from the resource in use."""
if not self.current:
print('There are no resources in use. Use the command "open".')
return
try:
print(self.current.read())
except Exception as e:
print(e) |
Send to the resource in use: send *IDN? | def do_write(self, args):
"""Send to the resource in use: send *IDN? """
if not self.current:
print('There are no resources in use. Use the command "open".')
return
try:
self.current.write(args)
except Exception as e:
print(e) |
Get or set timeout (in ms) for resource in use.
Get timeout:
timeout
Set timeout:
timeout <mstimeout> | def do_timeout(self, args):
"""Get or set timeout (in ms) for resource in use.
Get timeout:
timeout
Set timeout:
timeout <mstimeout>
"""
if not self.current:
print('There are no resources in use. Use the command "open".')
retu... |
Get or set the state for a visa attribute.
List all attributes:
attr
Get an attribute state:
attr <name>
Set an attribute state:
attr <name> <state> | def do_attr(self, args):
"""Get or set the state for a visa attribute.
List all attributes:
attr
Get an attribute state:
attr <name>
Set an attribute state:
attr <name> <state>
"""
if not self.current:
print('There ar... |
Get or set termination character for resource in use.
<termchar> can be one of: CR, LF, CRLF, NUL or None.
None is used to disable termination character
Get termination character:
termchar
Set termination character read or read+write:
termchar <termcha... | def do_termchar(self, args):
"""Get or set termination character for resource in use.
<termchar> can be one of: CR, LF, CRLF, NUL or None.
None is used to disable termination character
Get termination character:
termchar
Set termination character read or re... |
Exit the shell session. | def do_exit(self, arg):
"""Exit the shell session."""
if self.current:
self.current.close()
self.resource_manager.close()
del self.resource_manager
return True |
The timeout in milliseconds for all resource I/O operations.
Special values:
- **immediate** (``VI_TMO_IMMEDIATE``): 0
(for convenience, any value smaller than 1 is considered as 0)
- **infinite** (``VI_TMO_INFINITE``): ``float('+inf')``
(for convenience, None is considered... | def timeout(self):
"""The timeout in milliseconds for all resource I/O operations.
Special values:
- **immediate** (``VI_TMO_IMMEDIATE``): 0
(for convenience, any value smaller than 1 is considered as 0)
- **infinite** (``VI_TMO_INFINITE``): ``float('+inf')``
(for c... |
Get the extended information of this resource.
:param resource_name: Unique symbolic name of a resource.
:rtype: :class:`pyvisa.highlevel.ResourceInfo` | def resource_info(self):
"""Get the extended information of this resource.
:param resource_name: Unique symbolic name of a resource.
:rtype: :class:`pyvisa.highlevel.ResourceInfo`
"""
return self.visalib.parse_resource_extended(self._resource_manager.session, self.resource_name... |
The interface type of the resource as a number. | def interface_type(self):
"""The interface type of the resource as a number.
"""
return self.visalib.parse_resource(self._resource_manager.session,
self.resource_name)[0].interface_type |
Opens a session to the specified resource.
:param access_mode: Specifies the mode by which the resource is to be accessed.
:type access_mode: :class:`pyvisa.constants.AccessModes`
:param open_timeout: Milliseconds before the open operation times out.
:type open_timeout: int | def open(self, access_mode=constants.AccessModes.no_lock, open_timeout=5000):
"""Opens a session to the specified resource.
:param access_mode: Specifies the mode by which the resource is to be accessed.
:type access_mode: :class:`pyvisa.constants.AccessModes`
:param open_timeout: Milli... |
Closes the VISA session and marks the handle as invalid. | def close(self):
"""Closes the VISA session and marks the handle as invalid.
"""
try:
logger.debug('%s - closing', self._resource_name,
extra=self._logging_extra)
self.before_close()
self.visalib.close(self.session)
logger.... |
Sets the state of an attribute.
:param name: Attribute for which the state is to be modified. (Attributes.*)
:param state: The state of the attribute to be set for the specified object.
:return: return value of the library call.
:rtype: :class:`pyvisa.constants.StatusCode` | def set_visa_attribute(self, name, state):
"""Sets the state of an attribute.
:param name: Attribute for which the state is to be modified. (Attributes.*)
:param state: The state of the attribute to be set for the specified object.
:return: return value of the library call.
:rty... |
Installs handlers for event callbacks in this resource.
:param event_type: Logical event identifier.
:param handler: Interpreted as a valid reference to a handler to be installed by a client application.
:param user_handle: A value specified by an application that can be used for identifying ha... | def install_handler(self, event_type, handler, user_handle=None):
"""Installs handlers for event callbacks in this resource.
:param event_type: Logical event identifier.
:param handler: Interpreted as a valid reference to a handler to be installed by a client application.
:param user_ha... |
Uninstalls handlers for events in this resource.
:param event_type: Logical event identifier.
:param handler: Interpreted as a valid reference to a handler to be uninstalled by a client application.
:param user_handle: The user handle (ctypes object or None) returned by install_handler. | def uninstall_handler(self, event_type, handler, user_handle=None):
"""Uninstalls handlers for events in this resource.
:param event_type: Logical event identifier.
:param handler: Interpreted as a valid reference to a handler to be uninstalled by a client application.
:param user_handl... |
Disables notification of the specified event type(s) via the specified mechanism(s).
:param event_type: Logical event identifier.
:param mechanism: Specifies event handling mechanisms to be disabled.
(Constants.VI_QUEUE, .VI_HNDLR, .VI_SUSPEND_HNDLR, .VI_ALL_MECH) | def disable_event(self, event_type, mechanism):
"""Disables notification of the specified event type(s) via the specified mechanism(s).
:param event_type: Logical event identifier.
:param mechanism: Specifies event handling mechanisms to be disabled.
(Constants.VI_QUEU... |
Discards event occurrences for specified event types and mechanisms in this resource.
:param event_type: Logical event identifier.
:param mechanism: Specifies event handling mechanisms to be dicarded.
(Constants.VI_QUEUE, .VI_HNDLR, .VI_SUSPEND_HNDLR, .VI_ALL_MECH) | def discard_events(self, event_type, mechanism):
"""Discards event occurrences for specified event types and mechanisms in this resource.
:param event_type: Logical event identifier.
:param mechanism: Specifies event handling mechanisms to be dicarded.
(Constants.VI_QU... |
Enable event occurrences for specified event types and mechanisms in this resource.
:param event_type: Logical event identifier.
:param mechanism: Specifies event handling mechanisms to be enabled.
(Constants.VI_QUEUE, .VI_HNDLR, .VI_SUSPEND_HNDLR)
:param context: Not... | def enable_event(self, event_type, mechanism, context=None):
"""Enable event occurrences for specified event types and mechanisms in this resource.
:param event_type: Logical event identifier.
:param mechanism: Specifies event handling mechanisms to be enabled.
(Consta... |
Waits for an occurrence of the specified event in this resource.
:param in_event_type: Logical identifier of the event(s) to wait for.
:param timeout: Absolute time period in time units that the resource shall wait for a specified event to
occur before returning the time elapsed... | def wait_on_event(self, in_event_type, timeout, capture_timeout=False):
"""Waits for an occurrence of the specified event in this resource.
:param in_event_type: Logical identifier of the event(s) to wait for.
:param timeout: Absolute time period in time units that the resource shall wait for a... |
Establish a shared lock to the resource.
:param timeout: Absolute time period (in milliseconds) that a resource
waits to get unlocked by the locking session before
returning an error. (Defaults to self.timeout)
:param requested_key: Access key used by ano... | def lock(self, timeout='default', requested_key=None):
"""Establish a shared lock to the resource.
:param timeout: Absolute time period (in milliseconds) that a resource
waits to get unlocked by the locking session before
returning an error. (Defaults to ... |
Establish an exclusive lock to the resource.
:param timeout: Absolute time period (in milliseconds) that a resource
waits to get unlocked by the locking session before
returning an error. (Defaults to self.timeout) | def lock_excl(self, timeout='default'):
"""Establish an exclusive lock to the resource.
:param timeout: Absolute time period (in milliseconds) that a resource
waits to get unlocked by the locking session before
returning an error. (Defaults to self.timeou... |
A context that locks
:param timeout: Absolute time period (in milliseconds) that a resource
waits to get unlocked by the locking session before
returning an error. (Defaults to self.timeout)
:param requested_key: When using default of 'exclusive' the lock... | def lock_context(self, timeout='default', requested_key='exclusive'):
"""A context that locks
:param timeout: Absolute time period (in milliseconds) that a resource
waits to get unlocked by the locking session before
returning an error. (Defaults to self.... |
Generates a list of PrettyTables from a string of HTML code. Each <table> in
the HTML becomes one PrettyTable object. | def from_html(html_code, **kwargs):
"""
Generates a list of PrettyTables from a string of HTML code. Each <table> in
the HTML becomes one PrettyTable object.
"""
parser = TableHandler(**kwargs)
parser.feed(html_code)
return parser.tables |
Generates a PrettyTables from a string of HTML code which contains only a
single <table> | def from_html_one(html_code, **kwargs):
"""
Generates a PrettyTables from a string of HTML code which contains only a
single <table>
"""
tables = from_html(html_code, **kwargs)
try:
assert len(tables) == 1
except AssertionError:
raise Exception("More than one <table> in prov... |
Add a row to the table
Arguments:
row - row of data, should be a list with as many elements as the table
has fields | def add_row(self, row):
"""Add a row to the table
Arguments:
row - row of data, should be a list with as many elements as the table
has fields"""
if self._field_names and len(row) != len(self._field_names):
raise Exception("Row has incorrect number of values, (act... |
Delete a row to the table
Arguments:
row_index - The index of the row you want to delete. Indexing starts at 0. | def del_row(self, row_index):
"""Delete a row to the table
Arguments:
row_index - The index of the row you want to delete. Indexing starts at 0."""
if row_index > len(self._rows)-1:
raise Exception("Cant delete row at index %d, table only has %d rows!" % (row_index, len(... |
Add a column to the table.
Arguments:
fieldname - name of the field to contain the new column of data
column - column of data, should be a list with as many elements as the
table has rows
align - desired alignment for this column - "l" for left, "c" for centre and "r" for right... | def add_column(self, fieldname, column, align="c", valign="t"):
"""Add a column to the table.
Arguments:
fieldname - name of the field to contain the new column of data
column - column of data, should be a list with as many elements as the
table has rows
align - desire... |
Return string representation of HTML formatted version of table in current state.
Arguments:
start - index of first data row to include in output
end - index of last data row to include in output PLUS ONE (list slice style)
fields - names of fields (columns) to include
header -... | def get_html_string(self, **kwargs):
"""Return string representation of HTML formatted version of table in current state.
Arguments:
start - index of first data row to include in output
end - index of last data row to include in output PLUS ONE (list slice style)
fields - name... |
iterates over the row and make each field unique | def make_fields_unique(self, fields):
"""
iterates over the row and make each field unique
"""
for i in range(0, len(fields)):
for j in range(i+1, len(fields)):
if fields[i] == fields[j]:
fields[j] += "'" |
Handles parsing response structure and translating API Exceptions | def meta_request(func):
""" Handles parsing response structure and translating API Exceptions """
def inner(self, resource, *args, **kwargs):
serialize_response = kwargs.pop('serialize', True)
try:
resp = func(self, resource, *args, **kwargs)
except ApiException as e:
... |
Stream events for a resource from the Kubernetes API
:param resource: The API resource object that will be used to query the API
:param namespace: The namespace to query
:param name: The name of the resource instance to query
:param label_selector: The label selector with which to filte... | def watch(self, resource, namespace=None, name=None, label_selector=None, field_selector=None, resource_version=None, timeout=None):
"""
Stream events for a resource from the Kubernetes API
:param resource: The API resource object that will be used to query the API
:param namespace: The... |
validate checks a kubernetes resource definition
Args:
definition (dict): resource definition
version (str): version of kubernetes to validate against
strict (bool): whether unexpected additional properties should be considered errors
Returns:
warnings (... | def validate(self, definition, version=None, strict=False):
"""validate checks a kubernetes resource definition
Args:
definition (dict): resource definition
version (str): version of kubernetes to validate against
strict (bool): whether unexpected additional properti... |
Takes a List body and return a dictionary with the following structure:
{
'api_version': str,
'kind': str,
'items': [{
'resource': Resource,
'name': str,
'namespace': str,
}]
... | def _items_to_resources(self, body):
""" Takes a List body and return a dictionary with the following structure:
{
'api_version': str,
'kind': str,
'items': [{
'resource': Resource,
'name': str,
... |
Discovers all API groups present in the cluster | def parse_api_groups(self, request_resources=False, update=False):
""" Discovers all API groups present in the cluster """
if not self._cache.get('resources') or update:
self._cache['resources'] = self._cache.get('resources', {})
groups_response = load_json(self.client.request('G... |
returns a dictionary of resources associated with provided (prefix, group, version) | def get_resources_for_api_version(self, prefix, group, version, preferred):
""" returns a dictionary of resources associated with provided (prefix, group, version)"""
resources = defaultdict(list)
subresources = {}
path = '/'.join(filter(None, [prefix, group, version]))
resourc... |
Same as search, but will throw an error if there are multiple or no
results. If there are multiple results and only one is an exact match
on api_version, that resource will be returned. | def get(self, **kwargs):
""" Same as search, but will throw an error if there are multiple or no
results. If there are multiple results and only one is an exact match
on api_version, that resource will be returned.
"""
results = self.search(**kwargs)
# If there ar... |
Returns the proper Exception class for the given kubernetes.client.rest.ApiException object
https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#success-codes | def api_exception(e):
"""
Returns the proper Exception class for the given kubernetes.client.rest.ApiException object
https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#success-codes
"""
_, _, exc_traceback = sys.exc_info()
tb = '\n'.join(traceback.format_t... |
Adds a device to the list of devices we know about. | def add_device(dev):
"""Adds a device to the list of devices we know about."""
global DEV_IDX, DEFAULT_DEV
with DEV_LOCK:
for idx in range(len(DEVS)):
test_dev = DEVS[idx]
if test_dev.dev_name_short == dev.dev_name_short:
# This device is already in our list. ... |
Tries to find a board by board name. | def find_device_by_name(name):
"""Tries to find a board by board name."""
if not name:
return DEFAULT_DEV
with DEV_LOCK:
for dev in DEVS:
if dev.name == name:
return dev
return None |
Checks a USB device to see if it looks like a MicroPython device. | def is_micropython_usb_device(port):
"""Checks a USB device to see if it looks like a MicroPython device.
"""
if type(port).__name__ == 'Device':
# Assume its a pyudev.device.Device
if ('ID_BUS' not in port or port['ID_BUS'] != 'usb' or
'SUBSYSTEM' not in port or port['SUBSYSTEM'... |
Checks to see if the indicated portname is a MicroPython device
or not. | def is_micropython_usb_port(portName):
"""Checks to see if the indicated portname is a MicroPython device
or not.
"""
for port in serial.tools.list_ports.comports():
if port.device == portName:
return is_micropython_usb_device(port)
return False |
Sets up a thread to detect when USB devices are plugged and unplugged.
If the device looks like a MicroPython board, then it will automatically
connect to it. | def autoconnect():
"""Sets up a thread to detect when USB devices are plugged and unplugged.
If the device looks like a MicroPython board, then it will automatically
connect to it.
"""
if not USE_AUTOCONNECT:
return
try:
import pyudev
except ImportError:
return
... |
Thread which detects USB Serial devices connecting and disconnecting. | def autoconnect_thread(monitor):
"""Thread which detects USB Serial devices connecting and disconnecting."""
monitor.start()
monitor.filter_by('tty')
epoll = select.epoll()
epoll.register(monitor.fileno(), select.POLLIN)
while True:
try:
events = epoll.poll()
except... |
autoscan will check all of the serial ports to see if they have
a matching VID:PID for a MicroPython board. | def autoscan():
"""autoscan will check all of the serial ports to see if they have
a matching VID:PID for a MicroPython board.
"""
for port in serial.tools.list_ports.comports():
if is_micropython_usb_device(port):
connect_serial(port[0]) |
Collects the serial nunber and manufacturer into a string, if
the fields are available. | def extra_info(port):
"""Collects the serial nunber and manufacturer into a string, if
the fields are available."""
extra_items = []
if port.manufacturer:
extra_items.append("vendor '{}'".format(port.manufacturer))
if port.serial_number:
extra_items.append("serial '{}'".format(por... |
listports will display a list of all of the serial ports. | def listports():
"""listports will display a list of all of the serial ports.
"""
detected = False
for port in serial.tools.list_ports.comports():
detected = True
if port.vid:
micropythonPort = ''
if is_micropython_usb_device(port):
micropythonPort... |
Precede all special characters with a backslash. | def escape(str):
"""Precede all special characters with a backslash."""
out = ''
for char in str:
if char in '\\ ':
out += '\\'
out += char
return out |
Undoes the effects of the escape() function. | def unescape(str):
"""Undoes the effects of the escape() function."""
out = ''
prev_backslash = False
for char in str:
if not prev_backslash and char == '\\':
prev_backslash = True
continue
out += char
prev_backslash = False
return out |
Returns an aligned element. | def align_cell(fmt, elem, width):
"""Returns an aligned element."""
if fmt == "<":
return elem + ' ' * (width - len(elem))
if fmt == ">":
return ' ' * (width - len(elem)) + elem
return elem |
Prints a formatted list, adjusting the width so everything fits.
fmt contains a single character for each column. < indicates that the
column should be left justified, > indicates that the column should
be right justified. The last column may be a space which implies left
justification and no padding. | def column_print(fmt, rows, print_func):
"""Prints a formatted list, adjusting the width so everything fits.
fmt contains a single character for each column. < indicates that the
column should be left justified, > indicates that the column should
be right justified. The last column may be a space which ... |
Finds all of the files which match (used for completion). | def find_macthing_files(match):
"""Finds all of the files which match (used for completion)."""
last_slash = match.rfind('/')
if last_slash == -1:
dirname = '.'
match_prefix = match
result_prefix = ''
else:
dirname = match[0:last_slash]
match_prefix = match[last_s... |
Similar to print, but prints to stderr. | def print_err(*args, end='\n'):
"""Similar to print, but prints to stderr.
"""
print(*args, end=end, file=sys.stderr)
sys.stderr.flush() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.