INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Publishes end-to-end encryption keys for the device.
Said device must be the one used when logging in.
Args:
device_keys (dict): Optional. Identity keys for the device. The required
keys are:
| user_id (str): The ID of the user the device belongs to. Must m... | def upload_keys(self, device_keys=None, one_time_keys=None):
"""Publishes end-to-end encryption keys for the device.
Said device must be the one used when logging in.
Args:
device_keys (dict): Optional. Identity keys for the device. The required
keys are:
... |
Query HS for public keys by user and optionally device.
Args:
user_devices (dict): The devices whose keys to download. Should be
formatted as <user_id>: [<device_ids>]. No device_ids indicates
all devices for the corresponding user.
timeout (int): Optiona... | def query_keys(self, user_devices, timeout=None, token=None):
"""Query HS for public keys by user and optionally device.
Args:
user_devices (dict): The devices whose keys to download. Should be
formatted as <user_id>: [<device_ids>]. No device_ids indicates
a... |
Claims one-time keys for use in pre-key messages.
Args:
key_request (dict): The keys to be claimed. Format should be
<user_id>: { <device_id>: <algorithm> }.
timeout (int): Optional. The time (in milliseconds) to wait when
downloading keys from remote ser... | def claim_keys(self, key_request, timeout=None):
"""Claims one-time keys for use in pre-key messages.
Args:
key_request (dict): The keys to be claimed. Format should be
<user_id>: { <device_id>: <algorithm> }.
timeout (int): Optional. The time (in milliseconds) t... |
Gets a list of users who have updated their device identity keys.
Args:
from_token (str): The desired start point of the list. Should be the
next_batch field from a response to an earlier call to /sync.
to_token (str): The desired end point of the list. Should be the nex... | def key_changes(self, from_token, to_token):
"""Gets a list of users who have updated their device identity keys.
Args:
from_token (str): The desired start point of the list. Should be the
next_batch field from a response to an earlier call to /sync.
to_token (st... |
Sends send-to-device events to a set of client devices.
Args:
event_type (str): The type of event to send.
messages (dict): The messages to send. Format should be
<user_id>: {<device_id>: <event_content>}.
The device ID may also be '*', meaning all known ... | def send_to_device(self, event_type, messages, txn_id=None):
"""Sends send-to-device events to a set of client devices.
Args:
event_type (str): The type of event to send.
messages (dict): The messages to send. Format should be
<user_id>: {<device_id>: <event_cont... |
Register a guest account on this HS.
Note: HS must have guest registration enabled.
Returns:
str: Access Token
Raises:
MatrixRequestError | def register_as_guest(self):
""" Register a guest account on this HS.
Note: HS must have guest registration enabled.
Returns:
str: Access Token
Raises:
MatrixRequestError
"""
response = self.api.register(auth_body=None, kind='guest')
return... |
Register for a new account on this HS.
Args:
username (str): Account username
password (str): Account password
Returns:
str: Access Token
Raises:
MatrixRequestError | def register_with_password(self, username, password):
""" Register for a new account on this HS.
Args:
username (str): Account username
password (str): Account password
Returns:
str: Access Token
Raises:
MatrixRequestError
"""
... |
Deprecated. Use ``login`` with ``sync=False``.
Login to the homeserver.
Args:
username (str): Account username
password (str): Account password
Returns:
str: Access token
Raises:
MatrixRequestError | def login_with_password_no_sync(self, username, password):
"""Deprecated. Use ``login`` with ``sync=False``.
Login to the homeserver.
Args:
username (str): Account username
password (str): Account password
Returns:
str: Access token
Raises:... |
Deprecated. Use ``login`` with ``sync=True``.
Login to the homeserver.
Args:
username (str): Account username
password (str): Account password
limit (int): Deprecated. How many messages to return when syncing.
This will be replaced by a filter API in... | def login_with_password(self, username, password, limit=10):
"""Deprecated. Use ``login`` with ``sync=True``.
Login to the homeserver.
Args:
username (str): Account username
password (str): Account password
limit (int): Deprecated. How many messages to retur... |
Login to the homeserver.
Args:
username (str): Account username
password (str): Account password
limit (int): Deprecated. How many messages to return when syncing.
This will be replaced by a filter API in a later release.
sync (bool): Optional. Wh... | def login(self, username, password, limit=10, sync=True, device_id=None):
"""Login to the homeserver.
Args:
username (str): Account username
password (str): Account password
limit (int): Deprecated. How many messages to return when syncing.
This will ... |
Create a new room on the homeserver.
Args:
alias (str): The canonical_alias of the room.
is_public (bool): The public/private visibility of the room.
invitees (str[]): A set of user ids to invite into the room.
Returns:
Room
Raises:
... | def create_room(self, alias=None, is_public=False, invitees=None):
""" Create a new room on the homeserver.
Args:
alias (str): The canonical_alias of the room.
is_public (bool): The public/private visibility of the room.
invitees (str[]): A set of user ids to invite... |
Join a room.
Args:
room_id_or_alias (str): Room ID or an alias.
Returns:
Room
Raises:
MatrixRequestError | def join_room(self, room_id_or_alias):
""" Join a room.
Args:
room_id_or_alias (str): Room ID or an alias.
Returns:
Room
Raises:
MatrixRequestError
"""
response = self.api.join_room(room_id_or_alias)
room_id = (
r... |
Add a listener that will send a callback when the client recieves
an event.
Args:
callback (func(roomchunk)): Callback called when an event arrives.
event_type (str): The event_type to filter for.
Returns:
uuid.UUID: Unique id of the listener, can be used to... | def add_listener(self, callback, event_type=None):
""" Add a listener that will send a callback when the client recieves
an event.
Args:
callback (func(roomchunk)): Callback called when an event arrives.
event_type (str): The event_type to filter for.
Returns:
... |
Add a presence listener that will send a callback when the client receives
a presence update.
Args:
callback (func(roomchunk)): Callback called when a presence update arrives.
Returns:
uuid.UUID: Unique id of the listener, can be used to identify the listener. | def add_presence_listener(self, callback):
""" Add a presence listener that will send a callback when the client receives
a presence update.
Args:
callback (func(roomchunk)): Callback called when a presence update arrives.
Returns:
uuid.UUID: Unique id of the li... |
Keep listening for events forever.
Args:
timeout_ms (int): How long to poll the Home Server for before
retrying.
exception_handler (func(exception)): Optional exception handler
function which can be used to handle exceptions in the caller
thr... | def listen_forever(self, timeout_ms=30000, exception_handler=None,
bad_sync_timeout=5):
""" Keep listening for events forever.
Args:
timeout_ms (int): How long to poll the Home Server for before
retrying.
exception_handler (func(exception)):... |
Start a listener thread to listen for events in the background.
Args:
timeout (int): How long to poll the Home Server for before
retrying.
exception_handler (func(exception)): Optional exception handler
function which can be used to handle exceptions in the... | def start_listener_thread(self, timeout_ms=30000, exception_handler=None):
""" Start a listener thread to listen for events in the background.
Args:
timeout (int): How long to poll the Home Server for before
retrying.
exception_handler (func(exception)): Optional ... |
Stop listener thread running in the background | def stop_listener_thread(self):
""" Stop listener thread running in the background
"""
if self.sync_thread:
self.should_listen = False
self.sync_thread.join()
self.sync_thread = None |
Upload content to the home server and recieve a MXC url.
Args:
content (bytes): The data of the content.
content_type (str): The mimetype of the content.
filename (str): Optional. Filename of the content.
Raises:
MatrixUnexpectedResponse: If the homeserv... | def upload(self, content, content_type, filename=None):
""" Upload content to the home server and recieve a MXC url.
Args:
content (bytes): The data of the content.
content_type (str): The mimetype of the content.
filename (str): Optional. Filename of the content.
... |
Remove mapping of an alias
Args:
room_alias(str): The alias to be removed.
Returns:
bool: True if the alias is removed, False otherwise. | def remove_room_alias(self, room_alias):
"""Remove mapping of an alias
Args:
room_alias(str): The alias to be removed.
Returns:
bool: True if the alias is removed, False otherwise.
"""
try:
self.api.remove_room_alias(room_alias)
r... |
Uploads this device's identity keys to HS.
This device must be the one used when logging in. | def upload_identity_keys(self):
"""Uploads this device's identity keys to HS.
This device must be the one used when logging in.
"""
device_keys = {
'user_id': self.user_id,
'device_id': self.device_id,
'algorithms': self._algorithms,
'keys... |
Uploads new one-time keys to the HS, if needed.
Args:
force_update (bool): Fetch the number of one-time keys currently on the HS
before uploading, even if we already know one. In most cases this should
not be necessary, as we get this value from sync responses.
... | def upload_one_time_keys(self, force_update=False):
"""Uploads new one-time keys to the HS, if needed.
Args:
force_update (bool): Fetch the number of one-time keys currently on the HS
before uploading, even if we already know one. In most cases this should
no... |
Update data on one-time keys count and upload new ones if necessary.
Args:
counts (dict): Counts of keys currently on the HS for each key type. | def update_one_time_key_counts(self, counts):
"""Update data on one-time keys count and upload new ones if necessary.
Args:
counts (dict): Counts of keys currently on the HS for each key type.
"""
self.one_time_keys_manager.server_counts = counts
if self.one_time_key... |
Signs a JSON object.
NOTE: The object is modified in-place and the return value can be ignored.
As specified, this is done by encoding the JSON object without ``signatures`` or
keys grouped as ``unsigned``, using canonical encoding.
Args:
json (dict): The JSON object to si... | def sign_json(self, json):
"""Signs a JSON object.
NOTE: The object is modified in-place and the return value can be ignored.
As specified, this is done by encoding the JSON object without ``signatures`` or
keys grouped as ``unsigned``, using canonical encoding.
Args:
... |
Verifies a signed key object's signature.
The object must have a 'signatures' key associated with an object of the form
`user_id: {key_id: signature}`.
Args:
json (dict): The JSON object to verify.
user_key (str): The public ed25519 key which was used to sign the object... | def verify_json(self, json, user_key, user_id, device_id):
"""Verifies a signed key object's signature.
The object must have a 'signatures' key associated with an object of the form
`user_id: {key_id: signature}`.
Args:
json (dict): The JSON object to verify.
us... |
Get this user's display name.
Args:
room (Room): Optional. When specified, return the display name of the user
in this room.
Returns:
The display name. Defaults to the user ID if not set. | def get_display_name(self, room=None):
"""Get this user's display name.
Args:
room (Room): Optional. When specified, return the display name of the user
in this room.
Returns:
The display name. Defaults to the user ID if not set.
"""
if r... |
Set this users display name.
Args:
display_name (str): Display Name | def set_display_name(self, display_name):
""" Set this users display name.
Args:
display_name (str): Display Name
"""
self.displayname = display_name
return self.api.set_display_name(self.user_id, display_name) |
Creates a prepared request to send to the server with an encrypted message
and correct headers
:param session: The handle of the session to prepare requests with
:param endpoint: The endpoint/server to prepare requests to
:param message: The unencrypted message to send to the server
... | def prepare_encrypted_request(self, session, endpoint, message):
"""
Creates a prepared request to send to the server with an encrypted message
and correct headers
:param session: The handle of the session to prepare requests with
:param endpoint: The endpoint/server to prepare ... |
Takes in the encrypted response from the server and decrypts it
:param response: The response that needs to be decrytped
:return: The unencrypted message from the server | def parse_encrypted_response(self, response):
"""
Takes in the encrypted response from the server and decrypts it
:param response: The response that needs to be decrytped
:return: The unencrypted message from the server
"""
content_type = response.headers['Content-Type']... |
Create a Shell on the destination host
@param string i_stream: Which input stream to open. Leave this alone
unless you know what you're doing (default: stdin)
@param string o_stream: Which output stream to open. Leave this alone
unless you know what you're doing (default: stdout stderr... | def open_shell(self, i_stream='stdin', o_stream='stdout stderr',
working_directory=None, env_vars=None, noprofile=False,
codepage=437, lifetime=None, idle_timeout=None):
"""
Create a Shell on the destination host
@param string i_stream: Which input stream to... |
Close the shell
@param string shell_id: The shell id on the remote machine.
See #open_shell
@returns This should have more error checking but it just returns true
for now.
@rtype bool | def close_shell(self, shell_id):
"""
Close the shell
@param string shell_id: The shell id on the remote machine.
See #open_shell
@returns This should have more error checking but it just returns true
for now.
@rtype bool
"""
message_id = uuid.uui... |
Run a command on a machine with an open shell
@param string shell_id: The shell id on the remote machine.
See #open_shell
@param string command: The command to run on the remote machine
@param iterable of string arguments: An array of arguments for this
command
@param b... | def run_command(
self, shell_id, command, arguments=(), console_mode_stdin=True,
skip_cmd_shell=False):
"""
Run a command on a machine with an open shell
@param string shell_id: The shell id on the remote machine.
See #open_shell
@param string command: Th... |
Get the Output of the given shell and command
@param string shell_id: The shell id on the remote machine.
See #open_shell
@param string command_id: The command id on the remote machine.
See #run_command
#@return [Hash] Returns a Hash with a key :exitcode and :data.
Dat... | def get_command_output(self, shell_id, command_id):
"""
Get the Output of the given shell and command
@param string shell_id: The shell id on the remote machine.
See #open_shell
@param string command_id: The command id on the remote machine.
See #run_command
#@r... |
base64 encodes a Powershell script and executes the powershell
encoded script command | def run_ps(self, script):
"""base64 encodes a Powershell script and executes the powershell
encoded script command
"""
# must use utf16 little endian on windows
encoded_ps = b64encode(script.encode('utf_16_le')).decode('ascii')
rs = self.run_cmd('powershell -encodedcomman... |
converts a Powershell CLIXML message to a more human readable string | def _clean_error_msg(self, msg):
"""converts a Powershell CLIXML message to a more human readable string
"""
# TODO prepare unit test, beautify code
# if the msg does not start with this, return it as is
if msg.startswith(b"#< CLIXML\r\n"):
# for proper xml, we need t... |
strips any namespaces from an xml string | def _strip_namespace(self, xml):
"""strips any namespaces from an xml string"""
p = re.compile(b"xmlns=*[\"\"][^\"\"]*[\"\"]")
allmatches = p.finditer(xml)
for match in allmatches:
xml = xml.replace(match.group(), b"")
return xml |
Tell the GPIB device at the specified address to become controller in charge (CIC).
Corresponds to viGpibPassControl function of the VISA library.
:param primary_address: Primary address of the GPIB device to which you want to pass control.
:param secondary_address: Secondary address of the ta... | def pass_control(self, primary_address, secondary_address):
"""Tell the GPIB device at the specified address to become controller in charge (CIC).
Corresponds to viGpibPassControl function of the VISA library.
:param primary_address: Primary address of the GPIB device to which you want to pass... |
Decorator for VISA library classes. | def return_handler(module_logger, first_is_session=True):
"""Decorator for VISA library classes.
"""
def _outer(visa_library_method):
def _inner(self, session, *args, **kwargs):
ret_value = visa_library_method(*args, **kwargs)
module_logger.debug('%s%s -> %r',
... |
Return installed backends.
Backends are installed python packages named pyvisa-<something> where <something>
is the name of the backend.
:rtype: list | def list_backends():
"""Return installed backends.
Backends are installed python packages named pyvisa-<something> where <something>
is the name of the backend.
:rtype: list
"""
return ['ni'] + [name for (loader, name, ispkg) in pkgutil.iter_modules()
if name.startswith('p... |
Return the WRAPPER_CLASS for a given backend.
:rtype: pyvisa.highlevel.VisaLibraryBase | def get_wrapper_class(backend_name):
"""Return the WRAPPER_CLASS for a given backend.
:rtype: pyvisa.highlevel.VisaLibraryBase
"""
try:
return _WRAPPERS[backend_name]
except KeyError:
if backend_name == 'ni':
from .ctwrapper import NIVisaLibrary
_WRAPPERS['ni... |
Return an available default VISA wrapper as a string ('ni' or 'py').
Use NI if the binary is found, else try to use pyvisa-py.
If neither can be found, raise a ValueError. | def _get_default_wrapper():
"""Return an available default VISA wrapper as a string ('ni' or 'py').
Use NI if the binary is found, else try to use pyvisa-py.
If neither can be found, raise a ValueError.
"""
from .ctwrapper import NIVisaLibrary
ni_binary_found = bool(NIVisaLibrary.get_library_p... |
Helper function to create a VISA library wrapper.
In general, you should not use the function directly. The VISA library
wrapper will be created automatically when you create a ResourceManager object. | def open_visa_library(specification):
"""Helper function to create a VISA library wrapper.
In general, you should not use the function directly. The VISA library
wrapper will be created automatically when you create a ResourceManager object.
"""
if not specification:
logger.debug('No visa ... |
Last status in session.
Helper function to be called by resources properties. | def get_last_status_in_session(self, session):
"""Last status in session.
Helper function to be called by resources properties.
"""
try:
return self._last_status_in_session[session]
except KeyError:
raise errors.Error('The session %r does not seem to be v... |
A session dependent context for ignoring warnings
:param session: Unique logical identifier to a session.
:param warnings_constants: constants identifying the warnings to ignore. | def ignore_warning(self, session, *warnings_constants):
"""A session dependent context for ignoring warnings
:param session: Unique logical identifier to a session.
:param warnings_constants: constants identifying the warnings to ignore.
"""
self._ignore_warning_in_session[sessi... |
Installs handlers for event callbacks.
:param session: Unique logical identifier to a session.
: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 ... | def install_visa_handler(self, session, event_type, handler, user_handle=None):
"""Installs handlers for event callbacks.
:param session: Unique logical identifier to a session.
:param event_type: Logical event identifier.
:param handler: Interpreted as a valid reference to a handler to... |
Uninstalls handlers for events.
:param session: Unique logical identifier to a session.
: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 objec... | def uninstall_visa_handler(self, session, event_type, handler, user_handle=None):
"""Uninstalls handlers for events.
:param session: Unique logical identifier to a session.
:param event_type: Logical event identifier.
:param handler: Interpreted as a valid reference to a handler to be u... |
Uninstalls all previously installed handlers for a particular session.
:param session: Unique logical identifier to a session. If None, operates on all sessions. | def uninstall_all_visa_handlers(self, session):
"""Uninstalls all previously installed handlers for a particular session.
:param session: Unique logical identifier to a session. If None, operates on all sessions.
"""
if session is not None:
self.__uninstall_all_handlers_hel... |
Write in an 8-bit, 16-bit, 32-bit, 64-bit value to the specified memory space and offset.
Corresponds to viOut* functions of the VISA library.
:param session: Unique logical identifier to a session.
:param space: Specifies the address space. (Constants.*SPACE*)
:param offset: Offset (i... | def write_memory(self, session, space, offset, data, width, extended=False):
"""Write in an 8-bit, 16-bit, 32-bit, 64-bit value to the specified memory space and offset.
Corresponds to viOut* functions of the VISA library.
:param session: Unique logical identifier to a session.
:param ... |
Moves a block of data to local memory from the specified address space and offset.
Corresponds to viMoveIn* functions of the VISA library.
:param session: Unique logical identifier to a session.
:param space: Specifies the address space. (Constants.*SPACE*)
:param offset: Offset (in by... | def move_in(self, session, space, offset, length, width, extended=False):
"""Moves a block of data to local memory from the specified address space and offset.
Corresponds to viMoveIn* functions of the VISA library.
:param session: Unique logical identifier to a session.
:param space: ... |
Read an 8, 16, 32, or 64-bit value from the specified address.
Corresponds to viPeek* functions of the VISA library.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:param width: Number of bits to read.
:return: Data rea... | def peek(self, session, address, width):
"""Read an 8, 16, 32, or 64-bit value from the specified address.
Corresponds to viPeek* functions of the VISA library.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:param widt... |
Writes an 8, 16, 32, or 64-bit value from the specified address.
Corresponds to viPoke* functions of the VISA library.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:param width: Number of bits to read.
:param data: Da... | def poke(self, session, address, width, data):
"""Writes an 8, 16, 32, or 64-bit value from the specified address.
Corresponds to viPoke* functions of the VISA library.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:pa... |
Maps the specified memory space into the process's address space.
Corresponds to viMapAddress function of the VISA library.
:param session: Unique logical identifier to a session.
:param map_space: Specifies the address space to map. (Constants.*SPACE*)
:param map_base: Offset (in byte... | def map_address(self, session, map_space, map_base, map_size,
access=False, suggested=None):
"""Maps the specified memory space into the process's address space.
Corresponds to viMapAddress function of the VISA library.
:param session: Unique logical identifier to a session... |
Moves a block of data.
Corresponds to viMove function of the VISA library.
:param session: Unique logical identifier to a session.
:param source_space: Specifies the address space of the source.
:param source_offset: Offset of the starting address or register from which to read.
... | def move(self, session, source_space, source_offset, source_width, destination_space,
destination_offset, destination_width, length):
"""Moves a block of data.
Corresponds to viMove function of the VISA library.
:param session: Unique logical identifier to a session.
:para... |
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 session: Unique logical identifier to a session.
:param space: Specifies the address space. (Constants.*SPACE*)
:param offset: Offs... | def move_out_8(self, 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 session: Unique logical identifier to a session.
:pa... |
Opens a session to the specified resource.
Corresponds to viOpen function of the VISA library.
:param session: Resource Manager session (should always be a session returned from open_default_resource_manager()).
:param resource_name: Unique symbolic name of a resource.
:param access_mo... | def open(self, 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 session: Resource Manager session (should always be ... |
Parse a resource string to get extended interface information.
Corresponds to viParseRsrcEx function of the VISA library.
:param session: Resource Manager session (should always be the Default Resource Manager for VISA
returned from open_default_resource_manager()).
:pa... | def parse_resource_extended(self, session, resource_name):
"""Parse a resource string to get extended interface information.
Corresponds to viParseRsrcEx function of the VISA library.
:param session: Resource Manager session (should always be the Default Resource Manager for VISA
... |
Close the resource manager session. | def close(self):
"""Close the resource manager session.
"""
try:
logger.debug('Closing ResourceManager (session: %s)', self.session)
# Cleanly close all resources when closing the manager.
for resource in self._created_resources:
resource.close... |
Returns a dictionary mapping resource names to resource extended
information of all connected devices matching query.
For details of the VISA Resource Regular Expression syntax used in query,
refer to list_resources().
:param query: a VISA Resource Regular Expression used to match devi... | def list_resources_info(self, query='?*::INSTR'):
"""Returns a dictionary mapping resource names to resource extended
information of all connected devices matching query.
For details of the VISA Resource Regular Expression syntax used in query,
refer to list_resources().
:param... |
Get the (extended) information of a particular resource.
:param resource_name: Unique symbolic name of a resource.
:rtype: :class:`pyvisa.highlevel.ResourceInfo` | def resource_info(self, resource_name, extended=True):
"""Get the (extended) information of a particular resource.
:param resource_name: Unique symbolic name of a resource.
:rtype: :class:`pyvisa.highlevel.ResourceInfo`
"""
if extended:
ret, err = self.visalib.pars... |
Open the specified resource without wrapping into a class
:param resource_name: name or alias of the resource to open.
:param access_mode: access mode.
:type access_mode: :class:`pyvisa.constants.AccessModes`
:param open_timeout: time out to open.
:return: Unique logical identi... | def open_bare_resource(self, resource_name,
access_mode=constants.AccessModes.no_lock,
open_timeout=constants.VI_TMO_IMMEDIATE):
"""Open the specified resource without wrapping into a class
:param resource_name: name or alias of the resource to open.
... |
Return an instrument for the resource name.
:param resource_name: name or alias of the resource to open.
:param access_mode: access mode.
:type access_mode: :class:`pyvisa.constants.AccessModes`
:param open_timeout: time out to open.
:param resource_pyclass: resource python clas... | def open_resource(self, resource_name,
access_mode=constants.AccessModes.no_lock,
open_timeout=constants.VI_TMO_IMMEDIATE,
resource_pyclass=None,
**kwargs):
"""Return an instrument for the resource name.
:param reso... |
Register a subclass for a given interface type and resource class. | def register_subclass(cls):
"""Register a subclass for a given interface type and resource class.
"""
key = cls.interface_type, cls.resource_class
if key in _SUBCLASSES:
raise ValueError('Class already registered for %s and %s' % key)
_SUBCLASSES[(cls.interface_type, cls.resource_class)] ... |
Builds a resource name class by mixing a named tuple and ResourceName.
It also registers the class.
The field names are changed to lower case and the spaces replaced
by underscores ('_').
:param interface_type: the interface type
:type: interface_type: str
:param resource_parts: each of the p... | def build_rn_class(interface_type, resource_parts, resource_class,
is_rc_optional=True):
"""Builds a resource name class by mixing a named tuple and ResourceName.
It also registers the class.
The field names are changed to lower case and the spaces replaced
by underscores ('_').
... |
Filter a list of resources according to a query expression.
The search criteria specified in the query parameter has two parts:
1. a VISA regular expression over a resource string.
2. optional logical expression over attribute values
(not implemented in this function, see below).
.. note:... | def filter(resources, query):
"""Filter a list of resources according to a query expression.
The search criteria specified in the query parameter has two parts:
1. a VISA regular expression over a resource string.
2. optional logical expression over attribute values
(not implemented in thi... |
Filter a list of resources according to a query expression.
It accepts the optional part of the expression.
.. warning: This function is experimental and unsafe as it uses eval,
It also might require to open the resource.
:param resources: iterable of resources.
:param query: query ex... | def filter2(resources, query, open_resource):
"""Filter a list of resources according to a query expression.
It accepts the optional part of the expression.
.. warning: This function is experimental and unsafe as it uses eval,
It also might require to open the resource.
:param resourc... |
Exception used when the resource name cannot be parsed. | def bad_syntax(cls, syntax, resource_name, ex=None):
"""Exception used when the resource name cannot be parsed.
"""
if ex:
msg = "The syntax is '%s' (%s)." % (syntax, ex)
else:
msg = "The syntax is '%s'." % syntax
msg = "Could not parse '%s'. %s" % (reso... |
Exception used when the subclass for a given interface type / resource class pair
cannot be found. | def subclass_notfound(cls, interface_type_resource_class,
resource_name=None):
"""Exception used when the subclass for a given interface type / resource class pair
cannot be found.
"""
msg = "Parser for not found (%s)." % interface_type_resource_class
... |
Exception used when no resource class is provided and no default is found. | def rc_notfound(cls, interface_type, resource_name=None):
"""Exception used when no resource class is provided and no default is found.
"""
msg = "Resource class for %s not provided and default not found." % interface_type
if resource_name:
msg = "Could not parse '%s'. %s" ... |
Parse a resource name and return a ResourceName
:type resource_name: str
:rtype: ResourceName
:raises InvalidResourceName: if the resource name is invalid. | def from_string(cls, resource_name):
"""Parse a resource name and return a ResourceName
:type resource_name: str
:rtype: ResourceName
:raises InvalidResourceName: if the resource name is invalid.
"""
# TODO Remote VISA
uname = resource_name.upper()
for... |
Set the type of the user handle to install and uninstall handler signature.
:param library: the visa library wrapped by ctypes.
:param user_handle: use None for a void_p | def set_user_handle_type(library, user_handle):
"""Set the type of the user handle to install and uninstall handler signature.
:param library: the visa library wrapped by ctypes.
:param user_handle: use None for a void_p
"""
# Actually, it's not necessary to change ViHndlr *globally*. However,
... |
Set the signatures of most visa functions in the library.
All instrumentation related functions are specified here.
:param library: the visa library wrapped by ctypes.
:type library: ctypes.WinDLL or ctypes.CDLL
:param errcheck: error checking callable used for visa functions that return
... | def set_signatures(library, errcheck=None):
"""Set the signatures of most visa functions in the library.
All instrumentation related functions are specified here.
:param library: the visa library wrapped by ctypes.
:type library: ctypes.WinDLL or ctypes.CDLL
:param errcheck: error checking callabl... |
Set the signature of single function in a library.
:param library: ctypes wrapped library.
:type library: ctypes.WinDLL or ctypes.CDLL
:param function_name: name of the function as appears in the header file.
:type function_name: str
:param argtypes: a tuple of ctypes types to specify the argument ... | def set_signature(library, function_name, argtypes, restype, errcheck):
"""Set the signature of single function in a library.
:param library: ctypes wrapped library.
:type library: ctypes.WinDLL or ctypes.CDLL
:param function_name: name of the function as appears in the header file.
:type function_... |
Asserts the specified interrupt or signal.
Corresponds to viAssertIntrSignal function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param mode: How to assert the interrupt. (Constants.ASSERT*)
:param status_id: Thi... | def assert_interrupt_signal(library, session, mode, status_id):
"""Asserts the specified interrupt or signal.
Corresponds to viAssertIntrSignal function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param mode: How... |
Reads data from device or interface through the use of a formatted I/O read buffer.
Corresponds to viBufRead 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: ... | def buffer_read(library, session, count):
"""Reads data from device or interface through the use of a formatted I/O read buffer.
Corresponds to viBufRead function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param... |
Writes data to a formatted I/O write buffer synchronously.
Corresponds to viBufWrite 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: bytes
:return: number of w... | def buffer_write(library, session, data):
"""Writes data to a formatted I/O write buffer synchronously.
Corresponds to viBufWrite 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 writte... |
Disables notification of the specified event type(s) via the specified mechanism(s).
Corresponds to viDisableEvent 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.
... | def disable_event(library, session, event_type, mechanism):
"""Disables notification of the specified event type(s) via the specified mechanism(s).
Corresponds to viDisableEvent function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier ... |
Discards event occurrences for specified event types and mechanisms in a session.
Corresponds to viDiscardEvents 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.
:p... | def discard_events(library, session, event_type, mechanism):
"""Discards event occurrences for specified event types and mechanisms in a session.
Corresponds to viDiscardEvents function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier t... |
Enable event occurrences for specified event types and mechanisms in a session.
Corresponds to viEnableEvent 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... | def enable_event(library, session, event_type, mechanism, context=None):
"""Enable event occurrences for specified event types and mechanisms in a session.
Corresponds to viEnableEvent function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical iden... |
Returns the next resource from the list of resources found during a previous call to find_resources().
Corresponds to viFindNext function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param find_list: Describes a find list. This parameter must be created by find_resources().
... | def find_next(library, find_list):
"""Returns the next resource from the list of resources found during a previous call to find_resources().
Corresponds to viFindNext function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param find_list: Describes a find list. This paramet... |
Queries a VISA system to locate the resources associated with a specified interface.
Corresponds to viFindRsrc function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session (unused, just to uniform signatures).
:param query: A ... | def find_resources(library, session, query):
"""Queries a VISA system to locate the resources associated with a specified interface.
Corresponds to viFindRsrc function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session (unuse... |
Retrieves the state of an attribute.
Corresponds to viGetAttribute function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session, event, or find list.
:param attribute: Resource attribute for which the state query is made (see ... | def get_attribute(library, session, attribute):
"""Retrieves the state of an attribute.
Corresponds to viGetAttribute function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session, event, or find list.
:param attribute: Res... |
Write GPIB command bytes on the bus.
Corresponds to viGpibCommand function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param data: data tor write.
:type data: bytes
:return: Number of written bytes, return va... | def gpib_command(library, session, data):
"""Write GPIB command bytes on the bus.
Corresponds to viGpibCommand function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param data: data tor write.
:type data: byte... |
Tell the GPIB device at the specified address to become controller in charge (CIC).
Corresponds to viGpibPassControl function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param primary_address: Primary address of the ... | def gpib_pass_control(library, session, primary_address, secondary_address):
"""Tell the GPIB device at the specified address to become controller in charge (CIC).
Corresponds to viGpibPassControl function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique ... |
Reads in an 8-bit, 16-bit, 32-bit, or 64-bit value from the specified memory space and offset.
Corresponds to viIn* 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. (Con... | def read_memory(library, session, 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.
Corresponds to viIn* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logi... |
Reads in an 8-bit value from the specified memory space and offset.
Corresponds to viIn8* function 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*)
:param ... | def in_8(library, session, space, offset, extended=False):
"""Reads in an 8-bit value from the specified memory space and offset.
Corresponds to viIn8* function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param s... |
Reads in an 16-bit value from the specified memory space and offset.
Corresponds to viIn16* function 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 in_16(library, session, space, offset, extended=False):
"""Reads in an 16-bit value from the specified memory space and offset.
Corresponds to viIn16* function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:para... |
Reads in an 32-bit value from the specified memory space and offset.
Corresponds to viIn32* function 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 in_32(library, session, space, offset, extended=False):
"""Reads in an 32-bit value from the specified memory space and offset.
Corresponds to viIn32* function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:para... |
Reads in an 64-bit value from the specified memory space and offset.
Corresponds to viIn64* function 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 in_64(library, session, space, offset, extended=False):
"""Reads in an 64-bit value from the specified memory space and offset.
Corresponds to viIn64* function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:para... |
Installs handlers for event callbacks.
Corresponds to viInstallHandler 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 refer... | def install_handler(library, session, event_type, handler, user_handle):
"""Installs handlers for event callbacks.
Corresponds to viInstallHandler function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param event_... |
Establishes an access mode to the specified resources.
Corresponds to viLock function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param lock_type: Specifies the type of lock requested, either constants.AccessModes.ex... | def lock(library, session, lock_type, timeout, requested_key=None):
"""Establishes an access mode to the specified resources.
Corresponds to viLock function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param lock_... |
Maps the specified memory space into the process's address space.
Corresponds to viMapAddress function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param map_space: Specifies the address space to map. (Constants.*SPAC... | def map_address(library, session, map_space, map_base, map_size,
access=False, suggested=None):
"""Maps the specified memory space into the process's address space.
Corresponds to viMapAddress function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param sess... |
Map the specified trigger source line to the specified destination line.
Corresponds to viMapTrigger 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 from which to map. (Constant... | def map_trigger(library, session, trigger_source, trigger_destination, mode):
"""Map the specified trigger source line to the specified destination line.
Corresponds to viMapTrigger function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identif... |
Allocates memory from a resource's memory region.
Corresponds to viMemAlloc* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param size: Specifies the size of the allocation.
:param extended: Use 64 bits of... | def memory_allocation(library, session, size, extended=False):
"""Allocates memory from a resource's memory region.
Corresponds to viMemAlloc* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param size: Spe... |
Frees memory previously allocated using the memory_allocation() operation.
Corresponds to viMemFree* function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param offset: Offset of the memory to free.
:param extende... | def memory_free(library, session, offset, extended=False):
"""Frees memory previously allocated using the memory_allocation() operation.
Corresponds to viMemFree* function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
... |
Moves a block of data.
Corresponds to viMove function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param source_space: Specifies the address space of the source.
:param source_offset: Offset of the starting addres... | def move(library, session, source_space, source_offset, source_width, destination_space,
destination_offset, destination_width, length):
"""Moves a block of data.
Corresponds to viMove function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique log... |
Moves a block of data asynchronously.
Corresponds to viMoveAsync function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param source_space: Specifies the address space of the source.
:param source_offset: Offset of... | def move_asynchronously(library, session, source_space, source_offset, source_width,
destination_space, destination_offset,
destination_width, length):
"""Moves a block of data asynchronously.
Corresponds to viMoveAsync function of the VISA library.
:param l... |
Moves an 8-bit block of data from the specified address space and offset to local memory.
Corresponds to viMoveIn8* 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. (Con... | def move_in_8(library, session, space, offset, length, extended=False):
"""Moves an 8-bit block of data from the specified address space and offset to local memory.
Corresponds to viMoveIn8* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logic... |
Moves an 16-bit block of data from the specified address space and offset to local memory.
Corresponds to viMoveIn16* 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. (C... | def move_in_16(library, session, space, offset, length, extended=False):
"""Moves an 16-bit block of data from the specified address space and offset to local memory.
Corresponds to viMoveIn16* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique lo... |
Moves an 32-bit block of data from the specified address space and offset to local memory.
Corresponds to viMoveIn32* 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. (C... | def move_in_32(library, session, space, offset, length, extended=False):
"""Moves an 32-bit block of data from the specified address space and offset to local memory.
Corresponds to viMoveIn32* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique lo... |
Moves an 64-bit block of data from the specified address space and offset to local memory.
Corresponds to viMoveIn64* 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. (C... | def move_in_64(library, session, space, offset, length, extended=False):
"""Moves an 64-bit block of data from the specified address space and offset to local memory.
Corresponds to viMoveIn64* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique lo... |
Moves a block of data from local memory to the specified address space and offset.
Corresponds to viMoveOut* 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.... | def move_out(library, session, space, offset, length, data, width, extended=False):
"""Moves a block of data from local memory to the specified address space and offset.
Corresponds to viMoveOut* functions of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.