id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
247,800
diyan/pywinrm
winrm/__init__.py
Session._clean_error_msg
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 to remove the CLIXML part # (the first line) msg_xml = msg[11:] try: # remove the namespaces from the xml for easier processing msg_xml = self._strip_namespace(msg_xml) root = ET.fromstring(msg_xml) # the S node is the error message, find all S nodes nodes = root.findall("./S") new_msg = "" for s in nodes: # append error msg string to result, also # the hex chars represent CRLF so we replace with newline new_msg += s.text.replace("_x000D__x000A_", "\n") except Exception as e: # if any of the above fails, the msg was not true xml # print a warning and return the orignal string # TODO do not print, raise user defined error instead print("Warning: there was a problem converting the Powershell" " error message: %s" % (e)) else: # if new_msg was populated, that's our error message # otherwise the original error message will be used if len(new_msg): # remove leading and trailing whitespace while we are here return new_msg.strip().encode('utf-8') # either failed to decode CLIXML or there was nothing to decode # just return the original message return msg
python
def _clean_error_msg(self, msg): # 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 to remove the CLIXML part # (the first line) msg_xml = msg[11:] try: # remove the namespaces from the xml for easier processing msg_xml = self._strip_namespace(msg_xml) root = ET.fromstring(msg_xml) # the S node is the error message, find all S nodes nodes = root.findall("./S") new_msg = "" for s in nodes: # append error msg string to result, also # the hex chars represent CRLF so we replace with newline new_msg += s.text.replace("_x000D__x000A_", "\n") except Exception as e: # if any of the above fails, the msg was not true xml # print a warning and return the orignal string # TODO do not print, raise user defined error instead print("Warning: there was a problem converting the Powershell" " error message: %s" % (e)) else: # if new_msg was populated, that's our error message # otherwise the original error message will be used if len(new_msg): # remove leading and trailing whitespace while we are here return new_msg.strip().encode('utf-8') # either failed to decode CLIXML or there was nothing to decode # just return the original message return msg
[ "def", "_clean_error_msg", "(", "self", ",", "msg", ")", ":", "# 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 to remove the CLIXM...
converts a Powershell CLIXML message to a more human readable string
[ "converts", "a", "Powershell", "CLIXML", "message", "to", "a", "more", "human", "readable", "string" ]
ed4c2d991d9d0fe921dfc958c475c4c6a570519e
https://github.com/diyan/pywinrm/blob/ed4c2d991d9d0fe921dfc958c475c4c6a570519e/winrm/__init__.py#L57-L92
247,801
diyan/pywinrm
winrm/__init__.py
Session._strip_namespace
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
python
def _strip_namespace(self, xml): p = re.compile(b"xmlns=*[\"\"][^\"\"]*[\"\"]") allmatches = p.finditer(xml) for match in allmatches: xml = xml.replace(match.group(), b"") return xml
[ "def", "_strip_namespace", "(", "self", ",", "xml", ")", ":", "p", "=", "re", ".", "compile", "(", "b\"xmlns=*[\\\"\\\"][^\\\"\\\"]*[\\\"\\\"]\"", ")", "allmatches", "=", "p", ".", "finditer", "(", "xml", ")", "for", "match", "in", "allmatches", ":", "xml", ...
strips any namespaces from an xml string
[ "strips", "any", "namespaces", "from", "an", "xml", "string" ]
ed4c2d991d9d0fe921dfc958c475c4c6a570519e
https://github.com/diyan/pywinrm/blob/ed4c2d991d9d0fe921dfc958c475c4c6a570519e/winrm/__init__.py#L94-L100
247,802
pyvisa/pyvisa
pyvisa/errors.py
return_handler
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', visa_library_method.__name__, _args_to_str(args, kwargs), ret_value) try: ret_value = constants.StatusCode(ret_value) except ValueError: pass if first_is_session: self._last_status = ret_value self._last_status_in_session[session] = ret_value if ret_value < 0: raise VisaIOError(ret_value) if ret_value in self.issue_warning_on: if session and ret_value not in self._ignore_warning_in_session[session]: module_logger.warn(VisaIOWarning(ret_value), stacklevel=2) return ret_value return _inner return _outer
python
def return_handler(module_logger, first_is_session=True): def _outer(visa_library_method): def _inner(self, session, *args, **kwargs): ret_value = visa_library_method(*args, **kwargs) module_logger.debug('%s%s -> %r', visa_library_method.__name__, _args_to_str(args, kwargs), ret_value) try: ret_value = constants.StatusCode(ret_value) except ValueError: pass if first_is_session: self._last_status = ret_value self._last_status_in_session[session] = ret_value if ret_value < 0: raise VisaIOError(ret_value) if ret_value in self.issue_warning_on: if session and ret_value not in self._ignore_warning_in_session[session]: module_logger.warn(VisaIOWarning(ret_value), stacklevel=2) return ret_value return _inner return _outer
[ "def", "return_handler", "(", "module_logger", ",", "first_is_session", "=", "True", ")", ":", "def", "_outer", "(", "visa_library_method", ")", ":", "def", "_inner", "(", "self", ",", "session", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ret_...
Decorator for VISA library classes.
[ "Decorator", "for", "VISA", "library", "classes", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/errors.py#L501-L535
247,803
pyvisa/pyvisa
pyvisa/highlevel.py
list_backends
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('pyvisa-') and not name.endswith('-script')]
python
def list_backends(): return ['ni'] + [name for (loader, name, ispkg) in pkgutil.iter_modules() if name.startswith('pyvisa-') and not name.endswith('-script')]
[ "def", "list_backends", "(", ")", ":", "return", "[", "'ni'", "]", "+", "[", "name", "for", "(", "loader", ",", "name", ",", "ispkg", ")", "in", "pkgutil", ".", "iter_modules", "(", ")", "if", "name", ".", "startswith", "(", "'pyvisa-'", ")", "and", ...
Return installed backends. Backends are installed python packages named pyvisa-<something> where <something> is the name of the backend. :rtype: list
[ "Return", "installed", "backends", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L1412-L1421
247,804
pyvisa/pyvisa
pyvisa/highlevel.py
get_wrapper_class
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'] = NIVisaLibrary return NIVisaLibrary try: pkg = __import__('pyvisa-' + backend_name) _WRAPPERS[backend_name] = cls = pkg.WRAPPER_CLASS return cls except ImportError: raise ValueError('Wrapper not found: No package named pyvisa-%s' % backend_name)
python
def get_wrapper_class(backend_name): try: return _WRAPPERS[backend_name] except KeyError: if backend_name == 'ni': from .ctwrapper import NIVisaLibrary _WRAPPERS['ni'] = NIVisaLibrary return NIVisaLibrary try: pkg = __import__('pyvisa-' + backend_name) _WRAPPERS[backend_name] = cls = pkg.WRAPPER_CLASS return cls except ImportError: raise ValueError('Wrapper not found: No package named pyvisa-%s' % backend_name)
[ "def", "get_wrapper_class", "(", "backend_name", ")", ":", "try", ":", "return", "_WRAPPERS", "[", "backend_name", "]", "except", "KeyError", ":", "if", "backend_name", "==", "'ni'", ":", "from", ".", "ctwrapper", "import", "NIVisaLibrary", "_WRAPPERS", "[", "...
Return the WRAPPER_CLASS for a given backend. :rtype: pyvisa.highlevel.VisaLibraryBase
[ "Return", "the", "WRAPPER_CLASS", "for", "a", "given", "backend", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L1429-L1447
247,805
pyvisa/pyvisa
pyvisa/highlevel.py
open_visa_library
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 library specified, trying to find alternatives.') try: specification = os.environ['PYVISA_LIBRARY'] except KeyError: logger.debug('Environment variable PYVISA_LIBRARY is unset.') try: argument, wrapper = specification.split('@') except ValueError: argument = specification wrapper = None # Flag that we need a fallback, but avoid nested exceptions if wrapper is None: if argument: # some filename given wrapper = 'ni' else: wrapper = _get_default_wrapper() cls = get_wrapper_class(wrapper) try: return cls(argument) except Exception as e: logger.debug('Could not open VISA wrapper %s: %s\n%s', cls, str(argument), e) raise
python
def open_visa_library(specification): if not specification: logger.debug('No visa library specified, trying to find alternatives.') try: specification = os.environ['PYVISA_LIBRARY'] except KeyError: logger.debug('Environment variable PYVISA_LIBRARY is unset.') try: argument, wrapper = specification.split('@') except ValueError: argument = specification wrapper = None # Flag that we need a fallback, but avoid nested exceptions if wrapper is None: if argument: # some filename given wrapper = 'ni' else: wrapper = _get_default_wrapper() cls = get_wrapper_class(wrapper) try: return cls(argument) except Exception as e: logger.debug('Could not open VISA wrapper %s: %s\n%s', cls, str(argument), e) raise
[ "def", "open_visa_library", "(", "specification", ")", ":", "if", "not", "specification", ":", "logger", ".", "debug", "(", "'No visa library specified, trying to find alternatives.'", ")", "try", ":", "specification", "=", "os", ".", "environ", "[", "'PYVISA_LIBRARY'...
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.
[ "Helper", "function", "to", "create", "a", "VISA", "library", "wrapper", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L1474-L1505
247,806
pyvisa/pyvisa
pyvisa/highlevel.py
VisaLibraryBase.get_last_status_in_session
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 valid as it does not have any last status' % session)
python
def get_last_status_in_session(self, session): try: return self._last_status_in_session[session] except KeyError: raise errors.Error('The session %r does not seem to be valid as it does not have any last status' % session)
[ "def", "get_last_status_in_session", "(", "self", ",", "session", ")", ":", "try", ":", "return", "self", ".", "_last_status_in_session", "[", "session", "]", "except", "KeyError", ":", "raise", "errors", ".", "Error", "(", "'The session %r does not seem to be valid...
Last status in session. Helper function to be called by resources properties.
[ "Last", "status", "in", "session", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L154-L162
247,807
pyvisa/pyvisa
pyvisa/highlevel.py
VisaLibraryBase.ignore_warning
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[session].update(warnings_constants) yield self._ignore_warning_in_session[session].difference_update(warnings_constants)
python
def ignore_warning(self, session, *warnings_constants): self._ignore_warning_in_session[session].update(warnings_constants) yield self._ignore_warning_in_session[session].difference_update(warnings_constants)
[ "def", "ignore_warning", "(", "self", ",", "session", ",", "*", "warnings_constants", ")", ":", "self", ".", "_ignore_warning_in_session", "[", "session", "]", ".", "update", "(", "warnings_constants", ")", "yield", "self", ".", "_ignore_warning_in_session", "[", ...
A session dependent context for ignoring warnings :param session: Unique logical identifier to a session. :param warnings_constants: constants identifying the warnings to ignore.
[ "A", "session", "dependent", "context", "for", "ignoring", "warnings" ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L165-L173
247,808
pyvisa/pyvisa
pyvisa/highlevel.py
VisaLibraryBase.uninstall_all_visa_handlers
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_helper(session) else: for session in list(self.handlers): self.__uninstall_all_handlers_helper(session)
python
def uninstall_all_visa_handlers(self, session): if session is not None: self.__uninstall_all_handlers_helper(session) else: for session in list(self.handlers): self.__uninstall_all_handlers_helper(session)
[ "def", "uninstall_all_visa_handlers", "(", "self", ",", "session", ")", ":", "if", "session", "is", "not", "None", ":", "self", ".", "__uninstall_all_handlers_helper", "(", "session", ")", "else", ":", "for", "session", "in", "list", "(", "self", ".", "handl...
Uninstalls all previously installed handlers for a particular session. :param session: Unique logical identifier to a session. If None, operates on all sessions.
[ "Uninstalls", "all", "previously", "installed", "handlers", "for", "a", "particular", "session", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L214-L224
247,809
pyvisa/pyvisa
pyvisa/highlevel.py
VisaLibraryBase.write_memory
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 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 bits to read. :param extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ if width == 8: return self.out_8(session, space, offset, data, extended) elif width == 16: return self.out_16(session, space, offset, data, extended) elif width == 32: return self.out_32(session, space, offset, data, extended) elif width == 64: return self.out_64(session, space, offset, data, extended) raise ValueError('%s is not a valid size. Valid values are 8, 16, 32, or 64' % width)
python
def write_memory(self, session, space, offset, data, width, extended=False): if width == 8: return self.out_8(session, space, offset, data, extended) elif width == 16: return self.out_16(session, space, offset, data, extended) elif width == 32: return self.out_32(session, space, offset, data, extended) elif width == 64: return self.out_64(session, space, offset, data, extended) raise ValueError('%s is not a valid size. Valid values are 8, 16, 32, or 64' % width)
[ "def", "write_memory", "(", "self", ",", "session", ",", "space", ",", "offset", ",", "data", ",", "width", ",", "extended", "=", "False", ")", ":", "if", "width", "==", "8", ":", "return", "self", ".", "out_8", "(", "session", ",", "space", ",", "...
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 (in bytes) of the address or register from which to read. :param data: Data to write to bus. :param width: Number of bits to read. :param extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Write", "in", "an", "8", "-", "bit", "16", "-", "bit", "32", "-", "bit", "64", "-", "bit", "value", "to", "the", "specified", "memory", "space", "and", "offset", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L250-L273
247,810
pyvisa/pyvisa
pyvisa/highlevel.py
VisaLibraryBase.peek
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 width: Number of bits to read. :return: Data read from bus, return value of the library call. :rtype: bytes, :class:`pyvisa.constants.StatusCode` """ if width == 8: return self.peek_8(session, address) elif width == 16: return self.peek_16(session, address) elif width == 32: return self.peek_32(session, address) elif width == 64: return self.peek_64(session, address) raise ValueError('%s is not a valid size. Valid values are 8, 16, 32 or 64' % width)
python
def peek(self, session, address, width): if width == 8: return self.peek_8(session, address) elif width == 16: return self.peek_16(session, address) elif width == 32: return self.peek_32(session, address) elif width == 64: return self.peek_64(session, address) raise ValueError('%s is not a valid size. Valid values are 8, 16, 32 or 64' % width)
[ "def", "peek", "(", "self", ",", "session", ",", "address", ",", "width", ")", ":", "if", "width", "==", "8", ":", "return", "self", ".", "peek_8", "(", "session", ",", "address", ")", "elif", "width", "==", "16", ":", "return", "self", ".", "peek_...
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 read from bus, return value of the library call. :rtype: bytes, :class:`pyvisa.constants.StatusCode`
[ "Read", "an", "8", "16", "32", "or", "64", "-", "bit", "value", "from", "the", "specified", "address", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L328-L349
247,811
pyvisa/pyvisa
pyvisa/highlevel.py
VisaLibraryBase.poke
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. :param width: Number of bits to read. :param data: Data to be written to the bus. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ if width == 8: return self.poke_8(session, address, data) elif width == 16: return self.poke_16(session, address, data) elif width == 32: return self.poke_32(session, address, data) elif width == 64: return self.poke_64(session, address, data) raise ValueError('%s is not a valid size. Valid values are 8, 16, 32, or 64' % width)
python
def poke(self, session, address, width, data): if width == 8: return self.poke_8(session, address, data) elif width == 16: return self.poke_16(session, address, data) elif width == 32: return self.poke_32(session, address, data) elif width == 64: return self.poke_64(session, address, data) raise ValueError('%s is not a valid size. Valid values are 8, 16, 32, or 64' % width)
[ "def", "poke", "(", "self", ",", "session", ",", "address", ",", "width", ",", "data", ")", ":", "if", "width", "==", "8", ":", "return", "self", ".", "poke_8", "(", "session", ",", "address", ",", "data", ")", "elif", "width", "==", "16", ":", "...
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: Data to be written to the bus. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Writes", "an", "8", "16", "32", "or", "64", "-", "bit", "value", "from", "the", "specified", "address", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L351-L373
247,812
pyvisa/pyvisa
pyvisa/highlevel.py
ResourceManager.close
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() self.visalib.close(self.session) self.session = None self.visalib.resource_manager = None except errors.InvalidSession: pass
python
def close(self): 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() self.visalib.close(self.session) self.session = None self.visalib.resource_manager = None except errors.InvalidSession: pass
[ "def", "close", "(", "self", ")", ":", "try", ":", "logger", ".", "debug", "(", "'Closing ResourceManager (session: %s)'", ",", "self", ".", "session", ")", "# Cleanly close all resources when closing the manager.", "for", "resource", "in", "self", ".", "_created_reso...
Close the resource manager session.
[ "Close", "the", "resource", "manager", "session", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L1586-L1598
247,813
pyvisa/pyvisa
pyvisa/highlevel.py
ResourceManager.list_resources_info
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 query: a VISA Resource Regular Expression used to match devices. :return: Mapping of resource name to ResourceInfo :rtype: dict[str, :class:`pyvisa.highlevel.ResourceInfo`] """ return dict((resource, self.resource_info(resource)) for resource in self.list_resources(query))
python
def list_resources_info(self, query='?*::INSTR'): return dict((resource, self.resource_info(resource)) for resource in self.list_resources(query))
[ "def", "list_resources_info", "(", "self", ",", "query", "=", "'?*::INSTR'", ")", ":", "return", "dict", "(", "(", "resource", ",", "self", ".", "resource_info", "(", "resource", ")", ")", "for", "resource", "in", "self", ".", "list_resources", "(", "query...
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 devices. :return: Mapping of resource name to ResourceInfo :rtype: dict[str, :class:`pyvisa.highlevel.ResourceInfo`]
[ "Returns", "a", "dictionary", "mapping", "resource", "names", "to", "resource", "extended", "information", "of", "all", "connected", "devices", "matching", "query", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L1647-L1660
247,814
pyvisa/pyvisa
pyvisa/highlevel.py
ResourceManager.open_bare_resource
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. :param access_mode: access mode. :type access_mode: :class:`pyvisa.constants.AccessModes` :param open_timeout: time out to open. :return: Unique logical identifier reference to a session. """ return self.visalib.open(self.session, resource_name, access_mode, open_timeout)
python
def open_bare_resource(self, resource_name, access_mode=constants.AccessModes.no_lock, open_timeout=constants.VI_TMO_IMMEDIATE): return self.visalib.open(self.session, resource_name, access_mode, open_timeout)
[ "def", "open_bare_resource", "(", "self", ",", "resource_name", ",", "access_mode", "=", "constants", ".", "AccessModes", ".", "no_lock", ",", "open_timeout", "=", "constants", ".", "VI_TMO_IMMEDIATE", ")", ":", "return", "self", ".", "visalib", ".", "open", "...
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 identifier reference to a session.
[ "Open", "the", "specified", "resource", "without", "wrapping", "into", "a", "class" ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L1677-L1689
247,815
pyvisa/pyvisa
pyvisa/highlevel.py
ResourceManager.open_resource
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 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 class to use to instantiate the Resource. Defaults to None: select based on the resource name. :param kwargs: keyword arguments to be used to change instrument attributes after construction. :rtype: :class:`pyvisa.resources.Resource` """ if resource_pyclass is None: info = self.resource_info(resource_name, extended=True) try: resource_pyclass = self._resource_classes[(info.interface_type, info.resource_class)] except KeyError: resource_pyclass = self._resource_classes[(constants.InterfaceType.unknown, '')] logger.warning('There is no class defined for %r. Using Resource', (info.interface_type, info.resource_class)) res = resource_pyclass(self, resource_name) for key in kwargs.keys(): try: getattr(res, key) present = True except AttributeError: present = False except errors.InvalidSession: present = True if not present: raise ValueError('%r is not a valid attribute for type %s' % (key, res.__class__.__name__)) res.open(access_mode, open_timeout) self._created_resources.add(res) for key, value in kwargs.items(): setattr(res, key, value) return res
python
def open_resource(self, resource_name, access_mode=constants.AccessModes.no_lock, open_timeout=constants.VI_TMO_IMMEDIATE, resource_pyclass=None, **kwargs): if resource_pyclass is None: info = self.resource_info(resource_name, extended=True) try: resource_pyclass = self._resource_classes[(info.interface_type, info.resource_class)] except KeyError: resource_pyclass = self._resource_classes[(constants.InterfaceType.unknown, '')] logger.warning('There is no class defined for %r. Using Resource', (info.interface_type, info.resource_class)) res = resource_pyclass(self, resource_name) for key in kwargs.keys(): try: getattr(res, key) present = True except AttributeError: present = False except errors.InvalidSession: present = True if not present: raise ValueError('%r is not a valid attribute for type %s' % (key, res.__class__.__name__)) res.open(access_mode, open_timeout) self._created_resources.add(res) for key, value in kwargs.items(): setattr(res, key, value) return res
[ "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 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 class to use to instantiate the Resource. Defaults to None: select based on the resource name. :param kwargs: keyword arguments to be used to change instrument attributes after construction. :rtype: :class:`pyvisa.resources.Resource`
[ "Return", "an", "instrument", "for", "the", "resource", "name", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L1691-L1739
247,816
pyvisa/pyvisa
pyvisa/rname.py
register_subclass
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)] = cls _INTERFACE_TYPES.add(cls.interface_type) _RESOURCE_CLASSES[cls.interface_type].add(cls.resource_class) if cls.is_rc_optional: if cls.interface_type in _DEFAULT_RC: raise ValueError('Default already specified for %s' % cls.interface_type) _DEFAULT_RC[cls.interface_type] = cls.resource_class return cls
python
def register_subclass(cls): 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)] = cls _INTERFACE_TYPES.add(cls.interface_type) _RESOURCE_CLASSES[cls.interface_type].add(cls.resource_class) if cls.is_rc_optional: if cls.interface_type in _DEFAULT_RC: raise ValueError('Default already specified for %s' % cls.interface_type) _DEFAULT_RC[cls.interface_type] = cls.resource_class return cls
[ "def", "register_subclass", "(", "cls", ")", ":", "key", "=", "cls", ".", "interface_type", ",", "cls", ".", "resource_class", "if", "key", "in", "_SUBCLASSES", ":", "raise", "ValueError", "(", "'Class already registered for %s and %s'", "%", "key", ")", "_SUBCL...
Register a subclass for a given interface type and resource class.
[ "Register", "a", "subclass", "for", "a", "given", "interface", "type", "and", "resource", "class", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/rname.py#L86-L106
247,817
pyvisa/pyvisa
pyvisa/rname.py
InvalidResourceName.bad_syntax
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" % (resource_name, msg) return cls(msg)
python
def bad_syntax(cls, syntax, resource_name, ex=None): if ex: msg = "The syntax is '%s' (%s)." % (syntax, ex) else: msg = "The syntax is '%s'." % syntax msg = "Could not parse '%s'. %s" % (resource_name, msg) return cls(msg)
[ "def", "bad_syntax", "(", "cls", ",", "syntax", ",", "resource_name", ",", "ex", "=", "None", ")", ":", "if", "ex", ":", "msg", "=", "\"The syntax is '%s' (%s).\"", "%", "(", "syntax", ",", "ex", ")", "else", ":", "msg", "=", "\"The syntax is '%s'.\"", "...
Exception used when the resource name cannot be parsed.
[ "Exception", "used", "when", "the", "resource", "name", "cannot", "be", "parsed", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/rname.py#L43-L54
247,818
pyvisa/pyvisa
pyvisa/rname.py
InvalidResourceName.rc_notfound
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" % (resource_name, msg) return cls(msg)
python
def rc_notfound(cls, interface_type, resource_name=None): msg = "Resource class for %s not provided and default not found." % interface_type if resource_name: msg = "Could not parse '%s'. %s" % (resource_name, msg) return cls(msg)
[ "def", "rc_notfound", "(", "cls", ",", "interface_type", ",", "resource_name", "=", "None", ")", ":", "msg", "=", "\"Resource class for %s not provided and default not found.\"", "%", "interface_type", "if", "resource_name", ":", "msg", "=", "\"Could not parse '%s'. %s\""...
Exception used when no resource class is provided and no default is found.
[ "Exception", "used", "when", "no", "resource", "class", "is", "provided", "and", "no", "default", "is", "found", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/rname.py#L71-L80
247,819
pyvisa/pyvisa
pyvisa/rname.py
ResourceName.from_string
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 interface_type in _INTERFACE_TYPES: # Loop through all known interface types until we found one # that matches the beginning of the resource name if not uname.startswith(interface_type): continue if len(resource_name) == len(interface_type): parts = () else: parts = resource_name[len(interface_type):].split('::') # Try to match the last part of the resource name to # one of the known resource classes for the given interface type. # If not possible, use the default resource class # for the given interface type. if parts and parts[-1] in _RESOURCE_CLASSES[interface_type]: parts, resource_class = parts[:-1], parts[-1] else: try: resource_class = _DEFAULT_RC[interface_type] except KeyError: raise InvalidResourceName.rc_notfound(interface_type, resource_name) # Look for the subclass try: subclass = _SUBCLASSES[(interface_type, resource_class)] except KeyError: raise InvalidResourceName.subclass_notfound( (interface_type, resource_class), resource_name) # And create the object try: rn = subclass.from_parts(*parts) rn.user = resource_name return rn except ValueError as ex: raise InvalidResourceName.bad_syntax(subclass._visa_syntax, resource_name, ex) raise InvalidResourceName('Could not parse %s: unknown interface type' % resource_name)
python
def from_string(cls, resource_name): # TODO Remote VISA uname = resource_name.upper() for interface_type in _INTERFACE_TYPES: # Loop through all known interface types until we found one # that matches the beginning of the resource name if not uname.startswith(interface_type): continue if len(resource_name) == len(interface_type): parts = () else: parts = resource_name[len(interface_type):].split('::') # Try to match the last part of the resource name to # one of the known resource classes for the given interface type. # If not possible, use the default resource class # for the given interface type. if parts and parts[-1] in _RESOURCE_CLASSES[interface_type]: parts, resource_class = parts[:-1], parts[-1] else: try: resource_class = _DEFAULT_RC[interface_type] except KeyError: raise InvalidResourceName.rc_notfound(interface_type, resource_name) # Look for the subclass try: subclass = _SUBCLASSES[(interface_type, resource_class)] except KeyError: raise InvalidResourceName.subclass_notfound( (interface_type, resource_class), resource_name) # And create the object try: rn = subclass.from_parts(*parts) rn.user = resource_name return rn except ValueError as ex: raise InvalidResourceName.bad_syntax(subclass._visa_syntax, resource_name, ex) raise InvalidResourceName('Could not parse %s: unknown interface type' % resource_name)
[ "def", "from_string", "(", "cls", ",", "resource_name", ")", ":", "# TODO Remote VISA", "uname", "=", "resource_name", ".", "upper", "(", ")", "for", "interface_type", "in", "_INTERFACE_TYPES", ":", "# Loop through all known interface types until we found one", "# that ma...
Parse a resource name and return a ResourceName :type resource_name: str :rtype: ResourceName :raises InvalidResourceName: if the resource name is invalid.
[ "Parse", "a", "resource", "name", "and", "return", "a", "ResourceName" ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/rname.py#L139-L193
247,820
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
set_user_handle_type
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, # I don't want to break symmetry too much with all the other VPP43 # routines. global ViHndlr if user_handle is None: user_handle_p = c_void_p else: user_handle_p = POINTER(type(user_handle)) ViHndlr = FUNCTYPE(ViStatus, ViSession, ViEventType, ViEvent, user_handle_p) library.viInstallHandler.argtypes = [ViSession, ViEventType, ViHndlr, user_handle_p] library.viUninstallHandler.argtypes = [ViSession, ViEventType, ViHndlr, user_handle_p]
python
def set_user_handle_type(library, user_handle): # Actually, it's not necessary to change ViHndlr *globally*. However, # I don't want to break symmetry too much with all the other VPP43 # routines. global ViHndlr if user_handle is None: user_handle_p = c_void_p else: user_handle_p = POINTER(type(user_handle)) ViHndlr = FUNCTYPE(ViStatus, ViSession, ViEventType, ViEvent, user_handle_p) library.viInstallHandler.argtypes = [ViSession, ViEventType, ViHndlr, user_handle_p] library.viUninstallHandler.argtypes = [ViSession, ViEventType, ViHndlr, user_handle_p]
[ "def", "set_user_handle_type", "(", "library", ",", "user_handle", ")", ":", "# Actually, it's not necessary to change ViHndlr *globally*. However,", "# I don't want to break symmetry too much with all the other VPP43", "# routines.", "global", "ViHndlr", "if", "user_handle", "is", ...
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
[ "Set", "the", "type", "of", "the", "user", "handle", "to", "install", "and", "uninstall", "handler", "signature", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L52-L71
247,821
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
set_signature
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_name: str :param argtypes: a tuple of ctypes types to specify the argument types that the function accepts. :param restype: A ctypes type to specify the result type of the foreign function. Use None for void, a function not returning anything. :param errcheck: a callabe :raises: AttributeError """ func = getattr(library, function_name) func.argtypes = argtypes if restype is not None: func.restype = restype if errcheck is not None: func.errcheck = errcheck
python
def set_signature(library, function_name, argtypes, restype, errcheck): func = getattr(library, function_name) func.argtypes = argtypes if restype is not None: func.restype = restype if errcheck is not None: func.errcheck = errcheck
[ "def", "set_signature", "(", "library", ",", "function_name", ",", "argtypes", ",", "restype", ",", "errcheck", ")", ":", "func", "=", "getattr", "(", "library", ",", "function_name", ")", "func", ".", "argtypes", "=", "argtypes", "if", "restype", "is", "n...
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 types that the function accepts. :param restype: A ctypes type to specify the result type of the foreign function. Use None for void, a function not returning anything. :param errcheck: a callabe :raises: AttributeError
[ "Set", "the", "signature", "of", "single", "function", "in", "a", "library", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L226-L246
247,822
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
assert_interrupt_signal
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 to assert the interrupt. (Constants.ASSERT*) :param status_id: This is the status value to be presented during an interrupt acknowledge cycle. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ return library.viAssertIntrSignal(session, mode, status_id)
python
def assert_interrupt_signal(library, session, mode, status_id): return library.viAssertIntrSignal(session, mode, status_id)
[ "def", "assert_interrupt_signal", "(", "library", ",", "session", ",", "mode", ",", "status_id", ")", ":", "return", "library", ".", "viAssertIntrSignal", "(", "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 to assert the interrupt. (Constants.ASSERT*) :param status_id: This is the status value to be presented during an interrupt acknowledge cycle. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Asserts", "the", "specified", "interrupt", "or", "signal", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L292-L304
247,823
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
discard_events
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 to a session. :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) :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ return library.viDiscardEvents(session, event_type, mechanism)
python
def discard_events(library, session, event_type, mechanism): return library.viDiscardEvents(session, event_type, mechanism)
[ "def", "discard_events", "(", "library", ",", "session", ",", "event_type", ",", "mechanism", ")", ":", "return", "library", ".", "viDiscardEvents", "(", "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 to a session. :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) :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Discards", "event", "occurrences", "for", "specified", "event", "types", "and", "mechanisms", "in", "a", "session", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L413-L426
247,824
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
enable_event
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 identifier to a session. :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: :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ if context is None: context = constants.VI_NULL elif context != constants.VI_NULL: warnings.warn('In enable_event, context will be set VI_NULL.') context = constants.VI_NULL # according to spec VPP-4.3, section 3.7.3.1 return library.viEnableEvent(session, event_type, mechanism, context)
python
def enable_event(library, session, event_type, mechanism, context=None): if context is None: context = constants.VI_NULL elif context != constants.VI_NULL: warnings.warn('In enable_event, context will be set VI_NULL.') context = constants.VI_NULL # according to spec VPP-4.3, section 3.7.3.1 return library.viEnableEvent(session, event_type, mechanism, context)
[ "def", "enable_event", "(", "library", ",", "session", ",", "event_type", ",", "mechanism", ",", "context", "=", "None", ")", ":", "if", "context", "is", "None", ":", "context", "=", "constants", ".", "VI_NULL", "elif", "context", "!=", "constants", ".", ...
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 mechanism: Specifies event handling mechanisms to be enabled. (Constants.VI_QUEUE, .VI_HNDLR, .VI_SUSPEND_HNDLR) :param context: :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Enable", "event", "occurrences", "for", "specified", "event", "types", "and", "mechanisms", "in", "a", "session", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L429-L448
247,825
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
find_resources
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 (unused, just to uniform signatures). :param query: A regular expression followed by an optional logical expression. Use '?*' for all. :return: find_list, return_counter, instrument_description, return value of the library call. :rtype: ViFindList, int, unicode (Py2) or str (Py3), :class:`pyvisa.constants.StatusCode` """ find_list = ViFindList() return_counter = ViUInt32() instrument_description = create_string_buffer(constants.VI_FIND_BUFLEN) # [ViSession, ViString, ViPFindList, ViPUInt32, ViAChar] # ViString converts from (str, unicode, bytes) to bytes ret = library.viFindRsrc(session, query, byref(find_list), byref(return_counter), instrument_description) return find_list, return_counter.value, buffer_to_text(instrument_description), ret
python
def find_resources(library, session, query): find_list = ViFindList() return_counter = ViUInt32() instrument_description = create_string_buffer(constants.VI_FIND_BUFLEN) # [ViSession, ViString, ViPFindList, ViPUInt32, ViAChar] # ViString converts from (str, unicode, bytes) to bytes ret = library.viFindRsrc(session, query, byref(find_list), byref(return_counter), instrument_description) return find_list, return_counter.value, buffer_to_text(instrument_description), ret
[ "def", "find_resources", "(", "library", ",", "session", ",", "query", ")", ":", "find_list", "=", "ViFindList", "(", ")", "return_counter", "=", "ViUInt32", "(", ")", "instrument_description", "=", "create_string_buffer", "(", "constants", ".", "VI_FIND_BUFLEN", ...
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 regular expression followed by an optional logical expression. Use '?*' for all. :return: find_list, return_counter, instrument_description, return value of the library call. :rtype: ViFindList, int, unicode (Py2) or str (Py3), :class:`pyvisa.constants.StatusCode`
[ "Queries", "a", "VISA", "system", "to", "locate", "the", "resources", "associated", "with", "a", "specified", "interface", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L466-L486
247,826
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
gpib_command
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: bytes :return: Number of written bytes, return value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode` """ return_count = ViUInt32() # [ViSession, ViBuf, ViUInt32, ViPUInt32] ret = library.viGpibCommand(session, data, len(data), byref(return_count)) return return_count.value, ret
python
def gpib_command(library, session, data): return_count = ViUInt32() # [ViSession, ViBuf, ViUInt32, ViPUInt32] ret = library.viGpibCommand(session, data, len(data), byref(return_count)) return return_count.value, ret
[ "def", "gpib_command", "(", "library", ",", "session", ",", "data", ")", ":", "return_count", "=", "ViUInt32", "(", ")", "# [ViSession, ViBuf, ViUInt32, ViPUInt32]", "ret", "=", "library", ".", "viGpibCommand", "(", "session", ",", "data", ",", "len", "(", "da...
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 value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode`
[ "Write", "GPIB", "command", "bytes", "on", "the", "bus", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L534-L550
247,827
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
in_8
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 space: Specifies the address space. (Constants.*SPACE*) :param offset: Offset (in bytes) of the address or register from which to read. :param extended: Use 64 bits offset independent of the platform. :return: Data read from memory, return value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode` """ value_8 = ViUInt8() if extended: ret = library.viIn8Ex(session, space, offset, byref(value_8)) else: ret = library.viIn8(session, space, offset, byref(value_8)) return value_8.value, ret
python
def in_8(library, session, space, offset, extended=False): value_8 = ViUInt8() if extended: ret = library.viIn8Ex(session, space, offset, byref(value_8)) else: ret = library.viIn8(session, space, offset, byref(value_8)) return value_8.value, ret
[ "def", "in_8", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "extended", "=", "False", ")", ":", "value_8", "=", "ViUInt8", "(", ")", "if", "extended", ":", "ret", "=", "library", ".", "viIn8Ex", "(", "session", ",", "space", ",",...
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 offset: Offset (in bytes) of the address or register from which to read. :param extended: Use 64 bits offset independent of the platform. :return: Data read from memory, return value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode`
[ "Reads", "in", "an", "8", "-", "bit", "value", "from", "the", "specified", "memory", "space", "and", "offset", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L640-L658
247,828
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
in_16
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. :param space: Specifies the address space. (Constants.*SPACE*) :param offset: Offset (in bytes) of the address or register from which to read. :param extended: Use 64 bits offset independent of the platform. :return: Data read from memory, return value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode` """ value_16 = ViUInt16() if extended: ret = library.viIn16Ex(session, space, offset, byref(value_16)) else: ret = library.viIn16(session, space, offset, byref(value_16)) return value_16.value, ret
python
def in_16(library, session, space, offset, extended=False): value_16 = ViUInt16() if extended: ret = library.viIn16Ex(session, space, offset, byref(value_16)) else: ret = library.viIn16(session, space, offset, byref(value_16)) return value_16.value, ret
[ "def", "in_16", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "extended", "=", "False", ")", ":", "value_16", "=", "ViUInt16", "(", ")", "if", "extended", ":", "ret", "=", "library", ".", "viIn16Ex", "(", "session", ",", "space", ...
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*) :param offset: Offset (in bytes) of the address or register from which to read. :param extended: Use 64 bits offset independent of the platform. :return: Data read from memory, return value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode`
[ "Reads", "in", "an", "16", "-", "bit", "value", "from", "the", "specified", "memory", "space", "and", "offset", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L661-L679
247,829
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
in_32
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. :param space: Specifies the address space. (Constants.*SPACE*) :param offset: Offset (in bytes) of the address or register from which to read. :param extended: Use 64 bits offset independent of the platform. :return: Data read from memory, return value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode` """ value_32 = ViUInt32() if extended: ret = library.viIn32Ex(session, space, offset, byref(value_32)) else: ret = library.viIn32(session, space, offset, byref(value_32)) return value_32.value, ret
python
def in_32(library, session, space, offset, extended=False): value_32 = ViUInt32() if extended: ret = library.viIn32Ex(session, space, offset, byref(value_32)) else: ret = library.viIn32(session, space, offset, byref(value_32)) return value_32.value, ret
[ "def", "in_32", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "extended", "=", "False", ")", ":", "value_32", "=", "ViUInt32", "(", ")", "if", "extended", ":", "ret", "=", "library", ".", "viIn32Ex", "(", "session", ",", "space", ...
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*) :param offset: Offset (in bytes) of the address or register from which to read. :param extended: Use 64 bits offset independent of the platform. :return: Data read from memory, return value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode`
[ "Reads", "in", "an", "32", "-", "bit", "value", "from", "the", "specified", "memory", "space", "and", "offset", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L682-L700
247,830
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
in_64
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. :param space: Specifies the address space. (Constants.*SPACE*) :param offset: Offset (in bytes) of the address or register from which to read. :param extended: Use 64 bits offset independent of the platform. :return: Data read from memory, return value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode` """ value_64 = ViUInt64() if extended: ret = library.viIn64Ex(session, space, offset, byref(value_64)) else: ret = library.viIn64(session, space, offset, byref(value_64)) return value_64.value, ret
python
def in_64(library, session, space, offset, extended=False): value_64 = ViUInt64() if extended: ret = library.viIn64Ex(session, space, offset, byref(value_64)) else: ret = library.viIn64(session, space, offset, byref(value_64)) return value_64.value, ret
[ "def", "in_64", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "extended", "=", "False", ")", ":", "value_64", "=", "ViUInt64", "(", ")", "if", "extended", ":", "ret", "=", "library", ".", "viIn64Ex", "(", "session", ",", "space", ...
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*) :param offset: Offset (in bytes) of the address or register from which to read. :param extended: Use 64 bits offset independent of the platform. :return: Data read from memory, return value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode`
[ "Reads", "in", "an", "64", "-", "bit", "value", "from", "the", "specified", "memory", "space", "and", "offset", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L703-L721
247,831
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
map_trigger
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 identifier to a session. :param trigger_source: Source line from which to map. (Constants.TRIG*) :param trigger_destination: Destination line to which to map. (Constants.TRIG*) :param mode: :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ return library.viMapTrigger(session, trigger_source, trigger_destination, mode)
python
def map_trigger(library, session, trigger_source, trigger_destination, mode): return library.viMapTrigger(session, trigger_source, trigger_destination, mode)
[ "def", "map_trigger", "(", "library", ",", "session", ",", "trigger_source", ",", "trigger_destination", ",", "mode", ")", ":", "return", "library", ".", "viMapTrigger", "(", "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 identifier to a session. :param trigger_source: Source line from which to map. (Constants.TRIG*) :param trigger_destination: Destination line to which to map. (Constants.TRIG*) :param mode: :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Map", "the", "specified", "trigger", "source", "line", "to", "the", "specified", "destination", "line", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L838-L851
247,832
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
memory_allocation
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: Specifies the size of the allocation. :param extended: Use 64 bits offset independent of the platform. :return: offset of the allocated memory, return value of the library call. :rtype: offset, :class:`pyvisa.constants.StatusCode` """ offset = ViBusAddress() if extended: ret = library.viMemAllocEx(session, size, byref(offset)) else: ret = library.viMemAlloc(session, size, byref(offset)) return offset, ret
python
def memory_allocation(library, session, size, extended=False): offset = ViBusAddress() if extended: ret = library.viMemAllocEx(session, size, byref(offset)) else: ret = library.viMemAlloc(session, size, byref(offset)) return offset, ret
[ "def", "memory_allocation", "(", "library", ",", "session", ",", "size", ",", "extended", "=", "False", ")", ":", "offset", "=", "ViBusAddress", "(", ")", "if", "extended", ":", "ret", "=", "library", ".", "viMemAllocEx", "(", "session", ",", "size", ","...
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 offset independent of the platform. :return: offset of the allocated memory, return value of the library call. :rtype: offset, :class:`pyvisa.constants.StatusCode`
[ "Allocates", "memory", "from", "a", "resource", "s", "memory", "region", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L854-L871
247,833
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
move_asynchronously
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 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 address or register from which to read. :param source_width: Specifies the data width of the source. :param destination_space: Specifies the address space of the destination. :param destination_offset: Offset of the starting address or register to which to write. :param destination_width: Specifies the data width of the destination. :param length: Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width. :return: Job identifier of this asynchronous move operation, return value of the library call. :rtype: jobid, :class:`pyvisa.constants.StatusCode` """ job_id = ViJobId() ret = library.viMoveAsync(session, source_space, source_offset, source_width, destination_space, destination_offset, destination_width, length, byref(job_id)) return job_id, ret
python
def move_asynchronously(library, session, source_space, source_offset, source_width, destination_space, destination_offset, destination_width, length): job_id = ViJobId() ret = library.viMoveAsync(session, source_space, source_offset, source_width, destination_space, destination_offset, destination_width, length, byref(job_id)) return job_id, ret
[ "def", "move_asynchronously", "(", "library", ",", "session", ",", "source_space", ",", "source_offset", ",", "source_width", ",", "destination_space", ",", "destination_offset", ",", "destination_width", ",", "length", ")", ":", "job_id", "=", "ViJobId", "(", ")"...
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 the starting address or register from which to read. :param source_width: Specifies the data width of the source. :param destination_space: Specifies the address space of the destination. :param destination_offset: Offset of the starting address or register to which to write. :param destination_width: Specifies the data width of the destination. :param length: Number of elements to transfer, where the data width of the elements to transfer is identical to the source data width. :return: Job identifier of this asynchronous move operation, return value of the library call. :rtype: jobid, :class:`pyvisa.constants.StatusCode`
[ "Moves", "a", "block", "of", "data", "asynchronously", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L916-L940
247,834
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
move_in_8
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 logical identifier to a session. :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 of the elements to transfer is identical to the source data width. :param extended: Use 64 bits offset independent of the platform. :return: Data read from the bus, return value of the library call. :rtype: list, :class:`pyvisa.constants.StatusCode` """ buffer_8 = (ViUInt8 * length)() if extended: ret = library.viMoveIn8Ex(session, space, offset, length, buffer_8) else: ret = library.viMoveIn8(session, space, offset, length, buffer_8) return list(buffer_8), ret
python
def move_in_8(library, session, space, offset, length, extended=False): buffer_8 = (ViUInt8 * length)() if extended: ret = library.viMoveIn8Ex(session, space, offset, length, buffer_8) else: ret = library.viMoveIn8(session, space, offset, length, buffer_8) return list(buffer_8), ret
[ "def", "move_in_8", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "length", ",", "extended", "=", "False", ")", ":", "buffer_8", "=", "(", "ViUInt8", "*", "length", ")", "(", ")", "if", "extended", ":", "ret", "=", "library", ".",...
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. (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 of the elements to transfer is identical to the source data width. :param extended: Use 64 bits offset independent of the platform. :return: Data read from the bus, return value of the library call. :rtype: list, :class:`pyvisa.constants.StatusCode`
[ "Moves", "an", "8", "-", "bit", "block", "of", "data", "from", "the", "specified", "address", "space", "and", "offset", "to", "local", "memory", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L971-L991
247,835
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
move_in_16
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 logical identifier to a session. :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 of the elements to transfer is identical to the source data width. :param extended: Use 64 bits offset independent of the platform. :return: Data read from the bus, return value of the library call. :rtype: list, :class:`pyvisa.constants.StatusCode` """ buffer_16 = (ViUInt16 * length)() if extended: ret = library.viMoveIn16Ex(session, space, offset, length, buffer_16) else: ret = library.viMoveIn16(session, space, offset, length, buffer_16) return list(buffer_16), ret
python
def move_in_16(library, session, space, offset, length, extended=False): buffer_16 = (ViUInt16 * length)() if extended: ret = library.viMoveIn16Ex(session, space, offset, length, buffer_16) else: ret = library.viMoveIn16(session, space, offset, length, buffer_16) return list(buffer_16), ret
[ "def", "move_in_16", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "length", ",", "extended", "=", "False", ")", ":", "buffer_16", "=", "(", "ViUInt16", "*", "length", ")", "(", ")", "if", "extended", ":", "ret", "=", "library", "...
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. (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 of the elements to transfer is identical to the source data width. :param extended: Use 64 bits offset independent of the platform. :return: Data read from the bus, return value of the library call. :rtype: list, :class:`pyvisa.constants.StatusCode`
[ "Moves", "an", "16", "-", "bit", "block", "of", "data", "from", "the", "specified", "address", "space", "and", "offset", "to", "local", "memory", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L994-L1015
247,836
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
move_in_32
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 logical identifier to a session. :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 of the elements to transfer is identical to the source data width. :param extended: Use 64 bits offset independent of the platform. :return: Data read from the bus, return value of the library call. :rtype: list, :class:`pyvisa.constants.StatusCode` """ buffer_32 = (ViUInt32 * length)() if extended: ret = library.viMoveIn32Ex(session, space, offset, length, buffer_32) else: ret = library.viMoveIn32(session, space, offset, length, buffer_32) return list(buffer_32), ret
python
def move_in_32(library, session, space, offset, length, extended=False): buffer_32 = (ViUInt32 * length)() if extended: ret = library.viMoveIn32Ex(session, space, offset, length, buffer_32) else: ret = library.viMoveIn32(session, space, offset, length, buffer_32) return list(buffer_32), ret
[ "def", "move_in_32", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "length", ",", "extended", "=", "False", ")", ":", "buffer_32", "=", "(", "ViUInt32", "*", "length", ")", "(", ")", "if", "extended", ":", "ret", "=", "library", "...
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. (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 of the elements to transfer is identical to the source data width. :param extended: Use 64 bits offset independent of the platform. :return: Data read from the bus, return value of the library call. :rtype: list, :class:`pyvisa.constants.StatusCode`
[ "Moves", "an", "32", "-", "bit", "block", "of", "data", "from", "the", "specified", "address", "space", "and", "offset", "to", "local", "memory", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1018-L1039
247,837
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
move_in_64
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 logical identifier to a session. :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 of the elements to transfer is identical to the source data width. :param extended: Use 64 bits offset independent of the platform. :return: Data read from the bus, return value of the library call. :rtype: list, :class:`pyvisa.constants.StatusCode` """ buffer_64 = (ViUInt64 * length)() if extended: ret = library.viMoveIn64Ex(session, space, offset, length, buffer_64) else: ret = library.viMoveIn64(session, space, offset, length, buffer_64) return list(buffer_64), ret
python
def move_in_64(library, session, space, offset, length, extended=False): buffer_64 = (ViUInt64 * length)() if extended: ret = library.viMoveIn64Ex(session, space, offset, length, buffer_64) else: ret = library.viMoveIn64(session, space, offset, length, buffer_64) return list(buffer_64), ret
[ "def", "move_in_64", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "length", ",", "extended", "=", "False", ")", ":", "buffer_64", "=", "(", "ViUInt64", "*", "length", ")", "(", ")", "if", "extended", ":", "ret", "=", "library", "...
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. (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 of the elements to transfer is identical to the source data width. :param extended: Use 64 bits offset independent of the platform. :return: Data read from the bus, return value of the library call. :rtype: list, :class:`pyvisa.constants.StatusCode`
[ "Moves", "an", "64", "-", "bit", "block", "of", "data", "from", "the", "specified", "address", "space", "and", "offset", "to", "local", "memory", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1042-L1063
247,838
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
move_out_16
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: Unique logical identifier to a session. :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 of the elements to transfer is identical to the source data width. :param data: Data to write to bus. :param extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ converted_buffer = (ViUInt16 * length)(*tuple(data)) if extended: return library.viMoveOut16Ex(session, space, offset, length, converted_buffer) else: return library.viMoveOut16(session, space, offset, length, converted_buffer)
python
def move_out_16(library, session, space, offset, length, data, extended=False): converted_buffer = (ViUInt16 * length)(*tuple(data)) if extended: return library.viMoveOut16Ex(session, space, offset, length, converted_buffer) else: return library.viMoveOut16(session, space, offset, length, converted_buffer)
[ "def", "move_out_16", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "length", ",", "data", ",", "extended", "=", "False", ")", ":", "converted_buffer", "=", "(", "ViUInt16", "*", "length", ")", "(", "*", "tuple", "(", "data", ")", ...
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. (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 of the elements to transfer is identical to the source data width. :param data: Data to write to bus. :param extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Moves", "an", "16", "-", "bit", "block", "of", "data", "from", "local", "memory", "to", "the", "specified", "address", "space", "and", "offset", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1120-L1140
247,839
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
move_out_32
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: Unique logical identifier to a session. :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 of the elements to transfer is identical to the source data width. :param data: Data to write to bus. :param extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ converted_buffer = (ViUInt32 * length)(*tuple(data)) if extended: return library.viMoveOut32Ex(session, space, offset, length, converted_buffer) else: return library.viMoveOut32(session, space, offset, length, converted_buffer)
python
def move_out_32(library, session, space, offset, length, data, extended=False): converted_buffer = (ViUInt32 * length)(*tuple(data)) if extended: return library.viMoveOut32Ex(session, space, offset, length, converted_buffer) else: return library.viMoveOut32(session, space, offset, length, converted_buffer)
[ "def", "move_out_32", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "length", ",", "data", ",", "extended", "=", "False", ")", ":", "converted_buffer", "=", "(", "ViUInt32", "*", "length", ")", "(", "*", "tuple", "(", "data", ")", ...
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. (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 of the elements to transfer is identical to the source data width. :param data: Data to write to bus. :param extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Moves", "an", "32", "-", "bit", "block", "of", "data", "from", "local", "memory", "to", "the", "specified", "address", "space", "and", "offset", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1143-L1163
247,840
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
move_out_64
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: Unique logical identifier to a session. :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 of the elements to transfer is identical to the source data width. :param data: Data to write to bus. :param extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ converted_buffer = (ViUInt64 * length)(*tuple(data)) if extended: return library.viMoveOut64Ex(session, space, offset, length, converted_buffer) else: return library.viMoveOut64(session, space, offset, length, converted_buffer)
python
def move_out_64(library, session, space, offset, length, data, extended=False): converted_buffer = (ViUInt64 * length)(*tuple(data)) if extended: return library.viMoveOut64Ex(session, space, offset, length, converted_buffer) else: return library.viMoveOut64(session, space, offset, length, converted_buffer)
[ "def", "move_out_64", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "length", ",", "data", ",", "extended", "=", "False", ")", ":", "converted_buffer", "=", "(", "ViUInt64", "*", "length", ")", "(", "*", "tuple", "(", "data", ")", ...
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. (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 of the elements to transfer is identical to the source data width. :param data: Data to write to bus. :param extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Moves", "an", "64", "-", "bit", "block", "of", "data", "from", "local", "memory", "to", "the", "specified", "address", "space", "and", "offset", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1166-L1186
247,841
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
open_default_resource_manager
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 session, return value of the library call. :rtype: session, :class:`pyvisa.constants.StatusCode` """ session = ViSession() ret = library.viOpenDefaultRM(byref(session)) return session.value, ret
python
def open_default_resource_manager(library): session = ViSession() ret = library.viOpenDefaultRM(byref(session)) return session.value, ret
[ "def", "open_default_resource_manager", "(", "library", ")", ":", "session", "=", "ViSession", "(", ")", "ret", "=", "library", ".", "viOpenDefaultRM", "(", "byref", "(", "session", ")", ")", "return", "session", ".", "value", ",", "ret" ]
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: session, :class:`pyvisa.constants.StatusCode`
[ "This", "function", "returns", "a", "session", "to", "the", "Default", "Resource", "Manager", "resource", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1217-L1228
247,842
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
out_8
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. :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 extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ if extended: return library.viOut8Ex(session, space, offset, data) else: return library.viOut8(session, space, offset, data)
python
def out_8(library, session, space, offset, data, extended=False): if extended: return library.viOut8Ex(session, space, offset, data) else: return library.viOut8(session, space, offset, data)
[ "def", "out_8", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "data", ",", "extended", "=", "False", ")", ":", "if", "extended", ":", "return", "library", ".", "viOut8Ex", "(", "session", ",", "space", ",", "offset", ",", "data", ...
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*) :param offset: Offset (in bytes) of the address or register from which to read. :param data: Data to write to bus. :param extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Write", "in", "an", "8", "-", "bit", "value", "from", "the", "specified", "memory", "space", "and", "offset", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1256-L1273
247,843
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
out_16
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. :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 extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ if extended: return library.viOut16Ex(session, space, offset, data, extended=False) else: return library.viOut16(session, space, offset, data, extended=False)
python
def out_16(library, session, space, offset, data, extended=False): if extended: return library.viOut16Ex(session, space, offset, data, extended=False) else: return library.viOut16(session, space, offset, data, extended=False)
[ "def", "out_16", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "data", ",", "extended", "=", "False", ")", ":", "if", "extended", ":", "return", "library", ".", "viOut16Ex", "(", "session", ",", "space", ",", "offset", ",", "data", ...
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*) :param offset: Offset (in bytes) of the address or register from which to read. :param data: Data to write to bus. :param extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Write", "in", "an", "16", "-", "bit", "value", "from", "the", "specified", "memory", "space", "and", "offset", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1276-L1293
247,844
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
out_32
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. :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 extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ if extended: return library.viOut32Ex(session, space, offset, data) else: return library.viOut32(session, space, offset, data)
python
def out_32(library, session, space, offset, data, extended=False): if extended: return library.viOut32Ex(session, space, offset, data) else: return library.viOut32(session, space, offset, data)
[ "def", "out_32", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "data", ",", "extended", "=", "False", ")", ":", "if", "extended", ":", "return", "library", ".", "viOut32Ex", "(", "session", ",", "space", ",", "offset", ",", "data", ...
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*) :param offset: Offset (in bytes) of the address or register from which to read. :param data: Data to write to bus. :param extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Write", "in", "an", "32", "-", "bit", "value", "from", "the", "specified", "memory", "space", "and", "offset", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1296-L1313
247,845
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
out_64
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. :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 extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ if extended: return library.viOut64Ex(session, space, offset, data) else: return library.viOut64(session, space, offset, data)
python
def out_64(library, session, space, offset, data, extended=False): if extended: return library.viOut64Ex(session, space, offset, data) else: return library.viOut64(session, space, offset, data)
[ "def", "out_64", "(", "library", ",", "session", ",", "space", ",", "offset", ",", "data", ",", "extended", "=", "False", ")", ":", "if", "extended", ":", "return", "library", ".", "viOut64Ex", "(", "session", ",", "space", ",", "offset", ",", "data", ...
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*) :param offset: Offset (in bytes) of the address or register from which to read. :param data: Data to write to bus. :param extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Write", "in", "an", "64", "-", "bit", "value", "from", "the", "specified", "memory", "space", "and", "offset", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1316-L1333
247,846
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
parse_resource
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 Manager for VISA returned from open_default_resource_manager()). :param resource_name: Unique symbolic name of a resource. :return: Resource information with interface type and board number, return value of the library call. :rtype: :class:`pyvisa.highlevel.ResourceInfo`, :class:`pyvisa.constants.StatusCode` """ interface_type = ViUInt16() interface_board_number = ViUInt16() # [ViSession, ViRsrc, ViPUInt16, ViPUInt16] # ViRsrc converts from (str, unicode, bytes) to bytes ret = library.viParseRsrc(session, resource_name, byref(interface_type), byref(interface_board_number)) return ResourceInfo(constants.InterfaceType(interface_type.value), interface_board_number.value, None, None, None), ret
python
def parse_resource(library, session, resource_name): interface_type = ViUInt16() interface_board_number = ViUInt16() # [ViSession, ViRsrc, ViPUInt16, ViPUInt16] # ViRsrc converts from (str, unicode, bytes) to bytes ret = library.viParseRsrc(session, resource_name, byref(interface_type), byref(interface_board_number)) return ResourceInfo(constants.InterfaceType(interface_type.value), interface_board_number.value, None, None, None), ret
[ "def", "parse_resource", "(", "library", ",", "session", ",", "resource_name", ")", ":", "interface_type", "=", "ViUInt16", "(", ")", "interface_board_number", "=", "ViUInt16", "(", ")", "# [ViSession, ViRsrc, ViPUInt16, ViPUInt16]", "# ViRsrc converts from (str, unicode, b...
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_default_resource_manager()). :param resource_name: Unique symbolic name of a resource. :return: Resource information with interface type and board number, return value of the library call. :rtype: :class:`pyvisa.highlevel.ResourceInfo`, :class:`pyvisa.constants.StatusCode`
[ "Parse", "a", "resource", "string", "to", "get", "the", "interface", "information", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1336-L1357
247,847
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
peek
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 to read the value. :param width: Number of bits to read. :return: Data read from bus, return value of the library call. :rtype: bytes, :class:`pyvisa.constants.StatusCode` """ if width == 8: return peek_8(library, session, address) elif width == 16: return peek_16(library, session, address) elif width == 32: return peek_32(library, session, address) elif width == 64: return peek_64(library, session, address) raise ValueError('%s is not a valid size. Valid values are 8, 16, 32 or 64' % width)
python
def peek(library, session, address, width): if width == 8: return peek_8(library, session, address) elif width == 16: return peek_16(library, session, address) elif width == 32: return peek_32(library, session, address) elif width == 64: return peek_64(library, session, address) raise ValueError('%s is not a valid size. Valid values are 8, 16, 32 or 64' % width)
[ "def", "peek", "(", "library", ",", "session", ",", "address", ",", "width", ")", ":", "if", "width", "==", "8", ":", "return", "peek_8", "(", "library", ",", "session", ",", "address", ")", "elif", "width", "==", "16", ":", "return", "peek_16", "(",...
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 to read. :return: Data read from bus, return value of the library call. :rtype: bytes, :class:`pyvisa.constants.StatusCode`
[ "Read", "an", "8", "16", "or", "32", "-", "bit", "value", "from", "the", "specified", "address", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1397-L1419
247,848
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
peek_8
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 value. :return: Data read from bus, return value of the library call. :rtype: bytes, :class:`pyvisa.constants.StatusCode` """ value_8 = ViUInt8() ret = library.viPeek8(session, address, byref(value_8)) return value_8.value, ret
python
def peek_8(library, session, address): value_8 = ViUInt8() ret = library.viPeek8(session, address, byref(value_8)) return value_8.value, ret
[ "def", "peek_8", "(", "library", ",", "session", ",", "address", ")", ":", "value_8", "=", "ViUInt8", "(", ")", "ret", "=", "library", ".", "viPeek8", "(", "session", ",", "address", ",", "byref", "(", "value_8", ")", ")", "return", "value_8", ".", "...
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 value of the library call. :rtype: bytes, :class:`pyvisa.constants.StatusCode`
[ "Read", "an", "8", "-", "bit", "value", "from", "the", "specified", "address", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1422-L1435
247,849
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
peek_16
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 value. :return: Data read from bus, return value of the library call. :rtype: bytes, :class:`pyvisa.constants.StatusCode` """ value_16 = ViUInt16() ret = library.viPeek16(session, address, byref(value_16)) return value_16.value, ret
python
def peek_16(library, session, address): value_16 = ViUInt16() ret = library.viPeek16(session, address, byref(value_16)) return value_16.value, ret
[ "def", "peek_16", "(", "library", ",", "session", ",", "address", ")", ":", "value_16", "=", "ViUInt16", "(", ")", "ret", "=", "library", ".", "viPeek16", "(", "session", ",", "address", ",", "byref", "(", "value_16", ")", ")", "return", "value_16", "....
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 value of the library call. :rtype: bytes, :class:`pyvisa.constants.StatusCode`
[ "Read", "an", "16", "-", "bit", "value", "from", "the", "specified", "address", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1438-L1451
247,850
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
peek_32
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 value. :return: Data read from bus, return value of the library call. :rtype: bytes, :class:`pyvisa.constants.StatusCode` """ value_32 = ViUInt32() ret = library.viPeek32(session, address, byref(value_32)) return value_32.value, ret
python
def peek_32(library, session, address): value_32 = ViUInt32() ret = library.viPeek32(session, address, byref(value_32)) return value_32.value, ret
[ "def", "peek_32", "(", "library", ",", "session", ",", "address", ")", ":", "value_32", "=", "ViUInt32", "(", ")", "ret", "=", "library", ".", "viPeek32", "(", "session", ",", "address", ",", "byref", "(", "value_32", ")", ")", "return", "value_32", "....
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 value of the library call. :rtype: bytes, :class:`pyvisa.constants.StatusCode`
[ "Read", "an", "32", "-", "bit", "value", "from", "the", "specified", "address", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1454-L1467
247,851
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
peek_64
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 value. :return: Data read from bus, return value of the library call. :rtype: bytes, :class:`pyvisa.constants.StatusCode` """ value_64 = ViUInt64() ret = library.viPeek64(session, address, byref(value_64)) return value_64.value, ret
python
def peek_64(library, session, address): value_64 = ViUInt64() ret = library.viPeek64(session, address, byref(value_64)) return value_64.value, ret
[ "def", "peek_64", "(", "library", ",", "session", ",", "address", ")", ":", "value_64", "=", "ViUInt64", "(", ")", "ret", "=", "library", ".", "viPeek64", "(", "session", ",", "address", ",", "byref", "(", "value_64", ")", ")", "return", "value_64", "....
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 value of the library call. :rtype: bytes, :class:`pyvisa.constants.StatusCode`
[ "Read", "an", "64", "-", "bit", "value", "from", "the", "specified", "address", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1470-L1483
247,852
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
poke
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 address to read the value. :param width: Number of bits to read. :param data: Data to be written to the bus. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ if width == 8: return poke_8(library, session, address, data) elif width == 16: return poke_16(library, session, address, data) elif width == 32: return poke_32(library, session, address, data) raise ValueError('%s is not a valid size. Valid values are 8, 16 or 32' % width)
python
def poke(library, session, address, width, data): if width == 8: return poke_8(library, session, address, data) elif width == 16: return poke_16(library, session, address, data) elif width == 32: return poke_32(library, session, address, data) raise ValueError('%s is not a valid size. Valid values are 8, 16 or 32' % width)
[ "def", "poke", "(", "library", ",", "session", ",", "address", ",", "width", ",", "data", ")", ":", "if", "width", "==", "8", ":", "return", "poke_8", "(", "library", ",", "session", ",", "address", ",", "data", ")", "elif", "width", "==", "16", ":...
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 bits to read. :param data: Data to be written to the bus. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Writes", "an", "8", "16", "or", "32", "-", "bit", "value", "from", "the", "specified", "address", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1486-L1507
247,853
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
poke_8
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 the value. :param data: value to be written to the bus. :return: Data read from bus. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ return library.viPoke8(session, address, data)
python
def poke_8(library, session, address, data): return library.viPoke8(session, address, data)
[ "def", "poke_8", "(", "library", ",", "session", ",", "address", ",", "data", ")", ":", "return", "library", ".", "viPoke8", "(", "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 the value. :param data: value to be written to the bus. :return: Data read from bus. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Write", "an", "8", "-", "bit", "value", "from", "the", "specified", "address", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1510-L1523
247,854
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
poke_16
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 read the value. :param data: value to be written to the bus. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ return library.viPoke16(session, address, data)
python
def poke_16(library, session, address, data): return library.viPoke16(session, address, data)
[ "def", "poke_16", "(", "library", ",", "session", ",", "address", ",", "data", ")", ":", "return", "library", ".", "viPoke16", "(", "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 read the value. :param data: value to be written to the bus. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Write", "an", "16", "-", "bit", "value", "from", "the", "specified", "address", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1526-L1538
247,855
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
poke_32
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 read the value. :param data: value to be written to the bus. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ return library.viPoke32(session, address, data)
python
def poke_32(library, session, address, data): return library.viPoke32(session, address, data)
[ "def", "poke_32", "(", "library", ",", "session", ",", "address", ",", "data", ")", ":", "return", "library", ".", "viPoke32", "(", "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 read the value. :param data: value to be written to the bus. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Write", "an", "32", "-", "bit", "value", "from", "the", "specified", "address", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1541-L1553
247,856
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
poke_64
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 read the value. :param data: value to be written to the bus. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ return library.viPoke64(session, address, data)
python
def poke_64(library, session, address, data): return library.viPoke64(session, address, data)
[ "def", "poke_64", "(", "library", ",", "session", ",", "address", ",", "data", ")", ":", "return", "library", ".", "viPoke64", "(", "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 read the value. :param data: value to be written to the bus. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Write", "an", "64", "-", "bit", "value", "from", "the", "specified", "address", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1556-L1568
247,857
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
read_asynchronously
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 bytes to be read. :return: result, jobid, return value of the library call. :rtype: ctypes buffer, jobid, :class:`pyvisa.constants.StatusCode` """ buffer = create_string_buffer(count) job_id = ViJobId() ret = library.viReadAsync(session, buffer, count, byref(job_id)) return buffer, job_id, ret
python
def read_asynchronously(library, session, count): buffer = create_string_buffer(count) job_id = ViJobId() ret = library.viReadAsync(session, buffer, count, byref(job_id)) return buffer, job_id, ret
[ "def", "read_asynchronously", "(", "library", ",", "session", ",", "count", ")", ":", "buffer", "=", "create_string_buffer", "(", "count", ")", "job_id", "=", "ViJobId", "(", ")", "ret", "=", "library", ".", "viReadAsync", "(", "session", ",", "buffer", ",...
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 the library call. :rtype: ctypes buffer, jobid, :class:`pyvisa.constants.StatusCode`
[ "Reads", "data", "from", "device", "or", "interface", "asynchronously", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1588-L1602
247,858
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
read_stb
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 the library call. :rtype: int, :class:`pyvisa.constants.StatusCode` """ status = ViUInt16() ret = library.viReadSTB(session, byref(status)) return status.value, ret
python
def read_stb(library, session): status = ViUInt16() ret = library.viReadSTB(session, byref(status)) return status.value, ret
[ "def", "read_stb", "(", "library", ",", "session", ")", ":", "status", "=", "ViUInt16", "(", ")", "ret", "=", "library", ".", "viReadSTB", "(", "session", ",", "byref", "(", "status", ")", ")", "return", "status", ".", "value", ",", "ret" ]
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:`pyvisa.constants.StatusCode`
[ "Reads", "a", "status", "byte", "of", "the", "service", "request", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1605-L1617
247,859
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
read_to_file
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 filename: Name of file to which data will be written. :param count: Number of bytes to be read. :return: Number of bytes actually transferred, return value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode` """ return_count = ViUInt32() ret = library.viReadToFile(session, filename, count, return_count) return return_count, ret
python
def read_to_file(library, session, filename, count): return_count = ViUInt32() ret = library.viReadToFile(session, filename, count, return_count) return return_count, ret
[ "def", "read_to_file", "(", "library", ",", "session", ",", "filename", ",", "count", ")", ":", "return_count", "=", "ViUInt32", "(", ")", "ret", "=", "library", ".", "viReadToFile", "(", "session", ",", "filename", ",", "count", ",", "return_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 filename: Name of file to which data will be written. :param count: Number of bytes to be read. :return: Number of bytes actually transferred, return value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode`
[ "Read", "data", "synchronously", "and", "store", "the", "transferred", "data", "in", "a", "file", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1620-L1634
247,860
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
status_description
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. :param status: Status code to interpret. :return: - The user-readable string interpretation of the status code passed to the operation, - return value of the library call. :rtype: - unicode (Py2) or str (Py3) - :class:`pyvisa.constants.StatusCode` """ description = create_string_buffer(256) ret = library.viStatusDesc(session, status, description) return buffer_to_text(description), ret
python
def status_description(library, session, status): description = create_string_buffer(256) ret = library.viStatusDesc(session, status, description) return buffer_to_text(description), ret
[ "def", "status_description", "(", "library", ",", "session", ",", "status", ")", ":", "description", "=", "create_string_buffer", "(", "256", ")", "ret", "=", "library", ".", "viStatusDesc", "(", "session", ",", "status", ",", "description", ")", "return", "...
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: - The user-readable string interpretation of the status code passed to the operation, - return value of the library call. :rtype: - unicode (Py2) or str (Py3) - :class:`pyvisa.constants.StatusCode`
[ "Returns", "a", "user", "-", "readable", "description", "of", "the", "status", "code", "passed", "to", "the", "operation", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1667-L1682
247,861
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
terminate
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 degree: Constants.NULL :param job_id: Specifies an operation identifier. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ return library.viTerminate(session, degree, job_id)
python
def terminate(library, session, degree, job_id): return library.viTerminate(session, degree, job_id)
[ "def", "terminate", "(", "library", ",", "session", ",", "degree", ",", "job_id", ")", ":", "return", "library", ".", "viTerminate", "(", "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 degree: Constants.NULL :param job_id: Specifies an operation identifier. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Requests", "a", "VISA", "session", "to", "terminate", "normal", "execution", "of", "an", "operation", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1685-L1697
247,862
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
unmap_trigger
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: Unique logical identifier to a session. :param trigger_source: Source line used in previous map. (Constants.TRIG*) :param trigger_destination: Destination line used in previous map. (Constants.TRIG*) :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ return library.viUnmapTrigger(session, trigger_source, trigger_destination)
python
def unmap_trigger(library, session, trigger_source, trigger_destination): return library.viUnmapTrigger(session, trigger_source, trigger_destination)
[ "def", "unmap_trigger", "(", "library", ",", "session", ",", "trigger_source", ",", "trigger_destination", ")", ":", "return", "library", ".", "viUnmapTrigger", "(", "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: Unique logical identifier to a session. :param trigger_source: Source line used in previous map. (Constants.TRIG*) :param trigger_destination: Destination line used in previous map. (Constants.TRIG*) :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Undo", "a", "previous", "map", "from", "the", "specified", "trigger", "source", "line", "to", "the", "specified", "destination", "line", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1745-L1757
247,863
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
usb_control_in
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. :param session: Unique logical identifier to a session. :param request_type_bitmap_field: bmRequestType parameter of the setup stage of a USB control transfer. :param request_id: bRequest parameter of the setup stage of a USB control transfer. :param request_value: wValue parameter of the setup stage of a USB control transfer. :param index: wIndex parameter of the setup stage of a USB control transfer. This is usually the index of the interface or endpoint. :param length: wLength parameter of the setup stage of a USB control transfer. This value also specifies the size of the data buffer to receive the data from the optional data stage of the control transfer. :return: - The data buffer that receives the data from the optional data stage of the control transfer - return value of the library call. :rtype: - bytes - :class:`pyvisa.constants.StatusCode` """ buffer = create_string_buffer(length) return_count = ViUInt16() ret = library.viUsbControlIn(session, request_type_bitmap_field, request_id, request_value, index, length, buffer, byref(return_count)) return buffer.raw[:return_count.value], ret
python
def usb_control_in(library, session, request_type_bitmap_field, request_id, request_value, index, length=0): buffer = create_string_buffer(length) return_count = ViUInt16() ret = library.viUsbControlIn(session, request_type_bitmap_field, request_id, request_value, index, length, buffer, byref(return_count)) return buffer.raw[:return_count.value], ret
[ "def", "usb_control_in", "(", "library", ",", "session", ",", "request_type_bitmap_field", ",", "request_id", ",", "request_value", ",", "index", ",", "length", "=", "0", ")", ":", "buffer", "=", "create_string_buffer", "(", "length", ")", "return_count", "=", ...
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 a USB control transfer. :param request_id: bRequest parameter of the setup stage of a USB control transfer. :param request_value: wValue parameter of the setup stage of a USB control transfer. :param index: wIndex parameter of the setup stage of a USB control transfer. This is usually the index of the interface or endpoint. :param length: wLength parameter of the setup stage of a USB control transfer. This value also specifies the size of the data buffer to receive the data from the optional data stage of the control transfer. :return: - The data buffer that receives the data from the optional data stage of the control transfer - return value of the library call. :rtype: - bytes - :class:`pyvisa.constants.StatusCode`
[ "Performs", "a", "USB", "control", "pipe", "transfer", "from", "the", "device", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1760-L1786
247,864
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
usb_control_out
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. :param session: Unique logical identifier to a session. :param request_type_bitmap_field: bmRequestType parameter of the setup stage of a USB control transfer. :param request_id: bRequest parameter of the setup stage of a USB control transfer. :param request_value: wValue parameter of the setup stage of a USB control transfer. :param index: wIndex parameter of the setup stage of a USB control transfer. This is usually the index of the interface or endpoint. :param data: The data buffer that sends the data in the optional data stage of the control transfer. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """ length = len(data) return library.viUsbControlOut(session, request_type_bitmap_field, request_id, request_value, index, length, data)
python
def usb_control_out(library, session, request_type_bitmap_field, request_id, request_value, index, data=""): length = len(data) return library.viUsbControlOut(session, request_type_bitmap_field, request_id, request_value, index, length, data)
[ "def", "usb_control_out", "(", "library", ",", "session", ",", "request_type_bitmap_field", ",", "request_id", ",", "request_value", ",", "index", ",", "data", "=", "\"\"", ")", ":", "length", "=", "len", "(", "data", ")", "return", "library", ".", "viUsbCon...
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 USB control transfer. :param request_id: bRequest parameter of the setup stage of a USB control transfer. :param request_value: wValue parameter of the setup stage of a USB control transfer. :param index: wIndex parameter of the setup stage of a USB control transfer. This is usually the index of the interface or endpoint. :param data: The data buffer that sends the data in the optional data stage of the control transfer. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode`
[ "Performs", "a", "USB", "control", "pipe", "transfer", "to", "the", "device", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1789-L1808
247,865
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
wait_on_event
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. :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 error. The time unit is in milliseconds. :return: - Logical identifier of the event actually received - A handle specifying the unique occurrence of an event - return value of the library call. :rtype: - eventtype - event - :class:`pyvisa.constants.StatusCode` """ out_event_type = ViEventType() out_context = ViEvent() ret = library.viWaitOnEvent(session, in_event_type, timeout, byref(out_event_type), byref(out_context)) return out_event_type.value, out_context, ret
python
def wait_on_event(library, session, in_event_type, timeout): out_event_type = ViEventType() out_context = ViEvent() ret = library.viWaitOnEvent(session, in_event_type, timeout, byref(out_event_type), byref(out_context)) return out_event_type.value, out_context, ret
[ "def", "wait_on_event", "(", "library", ",", "session", ",", "in_event_type", ",", "timeout", ")", ":", "out_event_type", "=", "ViEventType", "(", ")", "out_context", "=", "ViEvent", "(", ")", "ret", "=", "library", ".", "viWaitOnEvent", "(", "session", ",",...
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 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 error. The time unit is in milliseconds. :return: - Logical identifier of the event actually received - A handle specifying the unique occurrence of an event - return value of the library call. :rtype: - eventtype - event - :class:`pyvisa.constants.StatusCode`
[ "Waits", "for", "an", "occurrence", "of", "the", "specified", "event", "for", "a", "given", "session", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1828-L1849
247,866
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
write_asynchronously
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 written. :return: Job ID of this asynchronous write operation, return value of the library call. :rtype: jobid, :class:`pyvisa.constants.StatusCode` """ job_id = ViJobId() # [ViSession, ViBuf, ViUInt32, ViPJobId] ret = library.viWriteAsync(session, data, len(data), byref(job_id)) return job_id, ret
python
def write_asynchronously(library, session, data): job_id = ViJobId() # [ViSession, ViBuf, ViUInt32, ViPJobId] ret = library.viWriteAsync(session, data, len(data), byref(job_id)) return job_id, ret
[ "def", "write_asynchronously", "(", "library", ",", "session", ",", "data", ")", ":", "job_id", "=", "ViJobId", "(", ")", "# [ViSession, ViBuf, ViUInt32, ViPJobId]", "ret", "=", "library", ".", "viWriteAsync", "(", "session", ",", "data", ",", "len", "(", "dat...
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 operation, return value of the library call. :rtype: jobid, :class:`pyvisa.constants.StatusCode`
[ "Writes", "data", "to", "device", "or", "interface", "asynchronously", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1870-L1884
247,867
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
write_from_file
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: Name of file from which data will be read. :param count: Number of bytes to be written. :return: Number of bytes actually transferred, return value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode` """ return_count = ViUInt32() ret = library.viWriteFromFile(session, filename, count, return_count) return return_count, ret
python
def write_from_file(library, session, filename, count): return_count = ViUInt32() ret = library.viWriteFromFile(session, filename, count, return_count) return return_count, ret
[ "def", "write_from_file", "(", "library", ",", "session", ",", "filename", ",", "count", ")", ":", "return_count", "=", "ViUInt32", "(", ")", "ret", "=", "library", ".", "viWriteFromFile", "(", "session", ",", "filename", ",", "count", ",", "return_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: Name of file from which data will be read. :param count: Number of bytes to be written. :return: Number of bytes actually transferred, return value of the library call. :rtype: int, :class:`pyvisa.constants.StatusCode`
[ "Take", "data", "from", "a", "file", "and", "write", "it", "out", "synchronously", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1887-L1901
247,868
pyvisa/pyvisa
pyvisa/attributes.py
Attribute.in_resource
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 AllSessionTypes: return True return session_type in cls.resources
python
def in_resource(cls, session_type): if cls.resources is AllSessionTypes: return True return session_type in cls.resources
[ "def", "in_resource", "(", "cls", ",", "session_type", ")", ":", "if", "cls", ".", "resources", "is", "AllSessionTypes", ":", "return", "True", "return", "session_type", "in", "cls", ".", "resources" ]
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
[ "Returns", "True", "if", "the", "attribute", "is", "part", "of", "a", "given", "session", "type", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/attributes.py#L116-L126
247,869
pyvisa/pyvisa
pyvisa/shell.py
VisaShell.do_list
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.items()): if not args: print('({0:2d}) {1}'.format(ndx, resource_name)) if value.alias: print(' alias: {}'.format(value.alias)) self.resources.append((resource_name, value.alias or None))
python
def do_list(self, args): 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.items()): if not args: print('({0:2d}) {1}'.format(ndx, resource_name)) if value.alias: print(' alias: {}'.format(value.alias)) self.resources.append((resource_name, value.alias or None))
[ "def", "do_list", "(", "self", ",", "args", ")", ":", "try", ":", "resources", "=", "self", ".", "resource_manager", ".", "list_resources_info", "(", ")", "except", "Exception", "as", "e", ":", "print", "(", "e", ")", "else", ":", "self", ".", "resourc...
List all connected resources.
[ "List", "all", "connected", "resources", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/shell.py#L121-L136
247,870
pyvisa/pyvisa
pyvisa/shell.py
VisaShell.do_close
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('The resource has been closed.') self.current = None self.prompt = self.default_prompt
python
def do_close(self, args): 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('The resource has been closed.') self.current = None self.prompt = self.default_prompt
[ "def", "do_close", "(", "self", ",", "args", ")", ":", "if", "not", "self", ".", "current", ":", "print", "(", "'There are no resources in use. Use the command \"open\".'", ")", "return", "try", ":", "self", ".", "current", ".", "close", "(", ")", "except", ...
Close resource in use.
[ "Close", "resource", "in", "use", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/shell.py#L179-L193
247,871
pyvisa/pyvisa
pyvisa/shell.py
VisaShell.do_read
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)
python
def do_read(self, args): 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)
[ "def", "do_read", "(", "self", ",", "args", ")", ":", "if", "not", "self", ".", "current", ":", "print", "(", "'There are no resources in use. Use the command \"open\".'", ")", "return", "try", ":", "print", "(", "self", ".", "current", ".", "read", "(", ")"...
Receive from the resource in use.
[ "Receive", "from", "the", "resource", "in", "use", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/shell.py#L207-L217
247,872
pyvisa/pyvisa
pyvisa/shell.py
VisaShell.do_attr
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 are no resources in use. Use the command "open".') return args = args.strip() if not args: self.print_attribute_list() return args = args.split(' ') if len(args) > 2: print('Invalid syntax, use `attr <name>` to get; or `attr <name> <value>` to set') elif len(args) == 1: # Get attr_name = args[0] if attr_name.startswith('VI_'): try: print(self.current.get_visa_attribute(getattr(constants, attr_name))) except Exception as e: print(e) else: try: print(getattr(self.current, attr_name)) except Exception as e: print(e) else: attr_name, attr_state = args[0], args[1] if attr_name.startswith('VI_'): try: attributeId = getattr(constants, attr_name) attr = attributes.AttributesByID[attributeId] datatype = attr.visa_type retcode = None if datatype == 'ViBoolean': if attr_state == 'True': attr_state = True elif attr_state == 'False': attr_state = False else: retcode = constants.StatusCode.error_nonsupported_attribute_state elif datatype in ['ViUInt8', 'ViUInt16', 'ViUInt32', 'ViInt8', 'ViInt16', 'ViInt32']: try: attr_state = int(attr_state) except ValueError: retcode = constants.StatusCode.error_nonsupported_attribute_state if not retcode: retcode = self.current.set_visa_attribute(attributeId, attr_state) if retcode: print('Error {}'.format(str(retcode))) else: print('Done') except Exception as e: print(e) else: print('Setting Resource Attributes by python name is not yet supported.') return try: print(getattr(self.current, attr_name)) print('Done') except Exception as e: print(e)
python
def do_attr(self, args): if not self.current: print('There are no resources in use. Use the command "open".') return args = args.strip() if not args: self.print_attribute_list() return args = args.split(' ') if len(args) > 2: print('Invalid syntax, use `attr <name>` to get; or `attr <name> <value>` to set') elif len(args) == 1: # Get attr_name = args[0] if attr_name.startswith('VI_'): try: print(self.current.get_visa_attribute(getattr(constants, attr_name))) except Exception as e: print(e) else: try: print(getattr(self.current, attr_name)) except Exception as e: print(e) else: attr_name, attr_state = args[0], args[1] if attr_name.startswith('VI_'): try: attributeId = getattr(constants, attr_name) attr = attributes.AttributesByID[attributeId] datatype = attr.visa_type retcode = None if datatype == 'ViBoolean': if attr_state == 'True': attr_state = True elif attr_state == 'False': attr_state = False else: retcode = constants.StatusCode.error_nonsupported_attribute_state elif datatype in ['ViUInt8', 'ViUInt16', 'ViUInt32', 'ViInt8', 'ViInt16', 'ViInt32']: try: attr_state = int(attr_state) except ValueError: retcode = constants.StatusCode.error_nonsupported_attribute_state if not retcode: retcode = self.current.set_visa_attribute(attributeId, attr_state) if retcode: print('Error {}'.format(str(retcode))) else: print('Done') except Exception as e: print(e) else: print('Setting Resource Attributes by python name is not yet supported.') return try: print(getattr(self.current, attr_name)) print('Done') except Exception as e: print(e)
[ "def", "do_attr", "(", "self", ",", "args", ")", ":", "if", "not", "self", ".", "current", ":", "print", "(", "'There are no resources in use. Use the command \"open\".'", ")", "return", "args", "=", "args", ".", "strip", "(", ")", "if", "not", "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>
[ "Get", "or", "set", "the", "state", "for", "a", "visa", "attribute", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/shell.py#L278-L356
247,873
pyvisa/pyvisa
pyvisa/shell.py
VisaShell.do_exit
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
python
def do_exit(self, arg): if self.current: self.current.close() self.resource_manager.close() del self.resource_manager return True
[ "def", "do_exit", "(", "self", ",", "arg", ")", ":", "if", "self", ".", "current", ":", "self", ".", "current", ".", "close", "(", ")", "self", ".", "resource_manager", ".", "close", "(", ")", "del", "self", ".", "resource_manager", "return", "True" ]
Exit the shell session.
[ "Exit", "the", "shell", "session", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/shell.py#L411-L418
247,874
pyvisa/pyvisa
pyvisa/resources/resource.py
Resource.resource_info
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)
python
def resource_info(self): return self.visalib.parse_resource_extended(self._resource_manager.session, self.resource_name)
[ "def", "resource_info", "(", "self", ")", ":", "return", "self", ".", "visalib", ".", "parse_resource_extended", "(", "self", ".", "_resource_manager", ".", "session", ",", "self", ".", "resource_name", ")" ]
Get the extended information of this resource. :param resource_name: Unique symbolic name of a resource. :rtype: :class:`pyvisa.highlevel.ResourceInfo`
[ "Get", "the", "extended", "information", "of", "this", "resource", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L176-L183
247,875
pyvisa/pyvisa
pyvisa/resources/resource.py
Resource.interface_type
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
python
def interface_type(self): return self.visalib.parse_resource(self._resource_manager.session, self.resource_name)[0].interface_type
[ "def", "interface_type", "(", "self", ")", ":", "return", "self", ".", "visalib", ".", "parse_resource", "(", "self", ".", "_resource_manager", ".", "session", ",", "self", ".", "resource_name", ")", "[", "0", "]", ".", "interface_type" ]
The interface type of the resource as a number.
[ "The", "interface", "type", "of", "the", "resource", "as", "a", "number", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L186-L190
247,876
pyvisa/pyvisa
pyvisa/resources/resource.py
Resource.close
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.debug('%s - is closed', self._resource_name, extra=self._logging_extra) self.session = None except errors.InvalidSession: pass
python
def close(self): try: logger.debug('%s - closing', self._resource_name, extra=self._logging_extra) self.before_close() self.visalib.close(self.session) logger.debug('%s - is closed', self._resource_name, extra=self._logging_extra) self.session = None except errors.InvalidSession: pass
[ "def", "close", "(", "self", ")", ":", "try", ":", "logger", ".", "debug", "(", "'%s - closing'", ",", "self", ".", "_resource_name", ",", "extra", "=", "self", ".", "_logging_extra", ")", "self", ".", "before_close", "(", ")", "self", ".", "visalib", ...
Closes the VISA session and marks the handle as invalid.
[ "Closes", "the", "VISA", "session", "and", "marks", "the", "handle", "as", "invalid", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L238-L250
247,877
pyvisa/pyvisa
pyvisa/resources/resource.py
Resource.install_handler
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_handle: A value specified by an application that can be used for identifying handlers uniquely for an event type. :returns: user handle (a ctypes object) """ return self.visalib.install_visa_handler(self.session, event_type, handler, user_handle)
python
def install_handler(self, event_type, handler, user_handle=None): return self.visalib.install_visa_handler(self.session, event_type, handler, user_handle)
[ "def", "install_handler", "(", "self", ",", "event_type", ",", "handler", ",", "user_handle", "=", "None", ")", ":", "return", "self", ".", "visalib", ".", "install_visa_handler", "(", "self", ".", "session", ",", "event_type", ",", "handler", ",", "user_han...
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 handlers uniquely for an event type. :returns: user handle (a ctypes object)
[ "Installs", "handlers", "for", "event", "callbacks", "in", "this", "resource", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L281-L291
247,878
pyvisa/pyvisa
pyvisa/resources/resource.py
Resource.uninstall_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_handle: The user handle (ctypes object or None) returned by install_handler. """ self.visalib.uninstall_visa_handler(self.session, event_type, handler, user_handle)
python
def uninstall_handler(self, event_type, handler, user_handle=None): self.visalib.uninstall_visa_handler(self.session, event_type, handler, user_handle)
[ "def", "uninstall_handler", "(", "self", ",", "event_type", ",", "handler", ",", "user_handle", "=", "None", ")", ":", "self", ".", "visalib", ".", "uninstall_visa_handler", "(", "self", ".", "session", ",", "event_type", ",", "handler", ",", "user_handle", ...
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.
[ "Uninstalls", "handlers", "for", "events", "in", "this", "resource", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L293-L301
247,879
pyvisa/pyvisa
pyvisa/resources/resource.py
Resource.discard_events
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_QUEUE, .VI_HNDLR, .VI_SUSPEND_HNDLR, .VI_ALL_MECH) """ self.visalib.discard_events(self.session, event_type, mechanism)
python
def discard_events(self, event_type, mechanism): self.visalib.discard_events(self.session, event_type, mechanism)
[ "def", "discard_events", "(", "self", ",", "event_type", ",", "mechanism", ")", ":", "self", ".", "visalib", ".", "discard_events", "(", "self", ".", "session", ",", "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_QUEUE, .VI_HNDLR, .VI_SUSPEND_HNDLR, .VI_ALL_MECH)
[ "Discards", "event", "occurrences", "for", "specified", "event", "types", "and", "mechanisms", "in", "this", "resource", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L312-L319
247,880
pyvisa/pyvisa
pyvisa/resources/resource.py
Resource.enable_event
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. (Constants.VI_QUEUE, .VI_HNDLR, .VI_SUSPEND_HNDLR) :param context: Not currently used, leave as None. """ self.visalib.enable_event(self.session, event_type, mechanism, context)
python
def enable_event(self, event_type, mechanism, context=None): self.visalib.enable_event(self.session, event_type, mechanism, context)
[ "def", "enable_event", "(", "self", ",", "event_type", ",", "mechanism", ",", "context", "=", "None", ")", ":", "self", ".", "visalib", ".", "enable_event", "(", "self", ".", "session", ",", "event_type", ",", "mechanism", ",", "context", ")" ]
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 currently used, leave as None.
[ "Enable", "event", "occurrences", "for", "specified", "event", "types", "and", "mechanisms", "in", "this", "resource", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L321-L329
247,881
pyvisa/pyvisa
pyvisa/resources/resource.py
Resource.wait_on_event
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 specified event to occur before returning the time elapsed error. The time unit is in milliseconds. None means waiting forever if necessary. :param capture_timeout: When True will not produce a VisaIOError(VI_ERROR_TMO) but instead return a WaitResponse with timed_out=True :return: A WaitResponse object that contains event_type, context and ret value. """ try: event_type, context, ret = self.visalib.wait_on_event(self.session, in_event_type, timeout) except errors.VisaIOError as exc: if capture_timeout and exc.error_code == constants.StatusCode.error_timeout: return WaitResponse(in_event_type, None, exc.error_code, self.visalib, timed_out=True) raise return WaitResponse(event_type, context, ret, self.visalib)
python
def wait_on_event(self, in_event_type, timeout, capture_timeout=False): try: event_type, context, ret = self.visalib.wait_on_event(self.session, in_event_type, timeout) except errors.VisaIOError as exc: if capture_timeout and exc.error_code == constants.StatusCode.error_timeout: return WaitResponse(in_event_type, None, exc.error_code, self.visalib, timed_out=True) raise return WaitResponse(event_type, context, ret, self.visalib)
[ "def", "wait_on_event", "(", "self", ",", "in_event_type", ",", "timeout", ",", "capture_timeout", "=", "False", ")", ":", "try", ":", "event_type", ",", "context", ",", "ret", "=", "self", ".", "visalib", ".", "wait_on_event", "(", "self", ".", "session",...
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 error. The time unit is in milliseconds. None means waiting forever if necessary. :param capture_timeout: When True will not produce a VisaIOError(VI_ERROR_TMO) but instead return a WaitResponse with timed_out=True :return: A WaitResponse object that contains event_type, context and ret value.
[ "Waits", "for", "an", "occurrence", "of", "the", "specified", "event", "in", "this", "resource", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L331-L348
247,882
pyvisa/pyvisa
pyvisa/resources/resource.py
Resource.lock
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 self.timeout) :param requested_key: Access key used by another session with which you want your session to share a lock or None to generate a new shared access key. :returns: A new shared access key if requested_key is None, otherwise, same value as the requested_key """ timeout = self.timeout if timeout == 'default' else timeout timeout = self._cleanup_timeout(timeout) return self.visalib.lock(self.session, constants.AccessModes.shared_lock, timeout, requested_key)[0]
python
def lock(self, timeout='default', requested_key=None): timeout = self.timeout if timeout == 'default' else timeout timeout = self._cleanup_timeout(timeout) return self.visalib.lock(self.session, constants.AccessModes.shared_lock, timeout, requested_key)[0]
[ "def", "lock", "(", "self", ",", "timeout", "=", "'default'", ",", "requested_key", "=", "None", ")", ":", "timeout", "=", "self", ".", "timeout", "if", "timeout", "==", "'default'", "else", "timeout", "timeout", "=", "self", ".", "_cleanup_timeout", "(", ...
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 another session with which you want your session to share a lock or None to generate a new shared access key. :returns: A new shared access key if requested_key is None, otherwise, same value as the requested_key
[ "Establish", "a", "shared", "lock", "to", "the", "resource", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L350-L365
247,883
pyvisa/pyvisa
pyvisa/resources/resource.py
Resource.lock_excl
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.timeout) """ timeout = self.timeout if timeout == 'default' else timeout timeout = self._cleanup_timeout(timeout) self.visalib.lock(self.session, constants.AccessModes.exclusive_lock, timeout, None)
python
def lock_excl(self, timeout='default'): timeout = self.timeout if timeout == 'default' else timeout timeout = self._cleanup_timeout(timeout) self.visalib.lock(self.session, constants.AccessModes.exclusive_lock, timeout, None)
[ "def", "lock_excl", "(", "self", ",", "timeout", "=", "'default'", ")", ":", "timeout", "=", "self", ".", "timeout", "if", "timeout", "==", "'default'", "else", "timeout", "timeout", "=", "self", ".", "_cleanup_timeout", "(", "timeout", ")", "self", ".", ...
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)
[ "Establish", "an", "exclusive", "lock", "to", "the", "resource", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L367-L377
247,884
pyvisa/pyvisa
pyvisa/resources/resource.py
Resource.lock_context
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.timeout) :param requested_key: When using default of 'exclusive' the lock is an exclusive lock. Otherwise it is the access key for the shared lock or None to generate a new shared access key. The returned context is the access_key if applicable. """ if requested_key == 'exclusive': self.lock_excl(timeout) access_key = None else: access_key = self.lock(timeout, requested_key) try: yield access_key finally: self.unlock()
python
def lock_context(self, timeout='default', requested_key='exclusive'): if requested_key == 'exclusive': self.lock_excl(timeout) access_key = None else: access_key = self.lock(timeout, requested_key) try: yield access_key finally: self.unlock()
[ "def", "lock_context", "(", "self", ",", "timeout", "=", "'default'", ",", "requested_key", "=", "'exclusive'", ")", ":", "if", "requested_key", "==", "'exclusive'", ":", "self", ".", "lock_excl", "(", "timeout", ")", "access_key", "=", "None", "else", ":", ...
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 is an exclusive lock. Otherwise it is the access key for the shared lock or None to generate a new shared access key. The returned context is the access_key if applicable.
[ "A", "context", "that", "locks" ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/resources/resource.py#L385-L407
247,885
pyvisa/pyvisa
pyvisa/thirdparty/prettytable.py
PrettyTable.del_row
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(self._rows))) del self._rows[row_index]
python
def del_row(self, row_index): if row_index > len(self._rows)-1: raise Exception("Cant delete row at index %d, table only has %d rows!" % (row_index, len(self._rows))) del self._rows[row_index]
[ "def", "del_row", "(", "self", ",", "row_index", ")", ":", "if", "row_index", ">", "len", "(", "self", ".", "_rows", ")", "-", "1", ":", "raise", "Exception", "(", "\"Cant delete row at index %d, table only has %d rows!\"", "%", "(", "row_index", ",", "len", ...
Delete a row to the table Arguments: row_index - The index of the row you want to delete. Indexing starts at 0.
[ "Delete", "a", "row", "to", "the", "table" ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/thirdparty/prettytable.py#L823-L833
247,886
pyvisa/pyvisa
pyvisa/thirdparty/prettytable.py
PrettyTable.get_html_string
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 - names of fields (columns) to include header - print a header showing field names (True or False) border - print a border around the table (True or False) hrules - controls printing of horizontal rules after rows. Allowed values: ALL, FRAME, HEADER, NONE vrules - controls printing of vertical rules between columns. Allowed values: FRAME, ALL, NONE int_format - controls formatting of integer data float_format - controls formatting of floating point data padding_width - number of spaces on either side of column data (only used if left and right paddings are None) left_padding_width - number of spaces on left hand side of column data right_padding_width - number of spaces on right hand side of column data sortby - name of field to sort rows by sort_key - sorting key function, applied to data points before sorting attributes - dictionary of name/value pairs to include as HTML attributes in the <table> tag xhtml - print <br/> tags if True, <br> tags if false""" options = self._get_options(kwargs) if options["format"]: string = self._get_formatted_html_string(options) else: string = self._get_simple_html_string(options) return string
python
def get_html_string(self, **kwargs): options = self._get_options(kwargs) if options["format"]: string = self._get_formatted_html_string(options) else: string = self._get_simple_html_string(options) return string
[ "def", "get_html_string", "(", "self", ",", "*", "*", "kwargs", ")", ":", "options", "=", "self", ".", "_get_options", "(", "kwargs", ")", "if", "options", "[", "\"format\"", "]", ":", "string", "=", "self", ".", "_get_formatted_html_string", "(", "options...
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 - print a header showing field names (True or False) border - print a border around the table (True or False) hrules - controls printing of horizontal rules after rows. Allowed values: ALL, FRAME, HEADER, NONE vrules - controls printing of vertical rules between columns. Allowed values: FRAME, ALL, NONE int_format - controls formatting of integer data float_format - controls formatting of floating point data padding_width - number of spaces on either side of column data (only used if left and right paddings are None) left_padding_width - number of spaces on left hand side of column data right_padding_width - number of spaces on right hand side of column data sortby - name of field to sort rows by sort_key - sorting key function, applied to data points before sorting attributes - dictionary of name/value pairs to include as HTML attributes in the <table> tag xhtml - print <br/> tags if True, <br> tags if false
[ "Return", "string", "representation", "of", "HTML", "formatted", "version", "of", "table", "in", "current", "state", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/thirdparty/prettytable.py#L1158-L1188
247,887
pyvisa/pyvisa
pyvisa/thirdparty/prettytable.py
TableHandler.make_fields_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] += "'"
python
def make_fields_unique(self, fields): for i in range(0, len(fields)): for j in range(i+1, len(fields)): if fields[i] == fields[j]: fields[j] += "'"
[ "def", "make_fields_unique", "(", "self", ",", "fields", ")", ":", "for", "i", "in", "range", "(", "0", ",", "len", "(", "fields", ")", ")", ":", "for", "j", "in", "range", "(", "i", "+", "1", ",", "len", "(", "fields", ")", ")", ":", "if", "...
iterates over the row and make each field unique
[ "iterates", "over", "the", "row", "and", "make", "each", "field", "unique" ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/thirdparty/prettytable.py#L1421-L1428
247,888
openshift/openshift-restclient-python
openshift/dynamic/client.py
meta_request
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: raise api_exception(e) if serialize_response: return serialize(resource, resp) return resp return inner
python
def meta_request(func): def inner(self, resource, *args, **kwargs): serialize_response = kwargs.pop('serialize', True) try: resp = func(self, resource, *args, **kwargs) except ApiException as e: raise api_exception(e) if serialize_response: return serialize(resource, resp) return resp return inner
[ "def", "meta_request", "(", "func", ")", ":", "def", "inner", "(", "self", ",", "resource", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "serialize_response", "=", "kwargs", ".", "pop", "(", "'serialize'", ",", "True", ")", "try", ":", "resp"...
Handles parsing response structure and translating API Exceptions
[ "Handles", "parsing", "response", "structure", "and", "translating", "API", "Exceptions" ]
5d86bf5ba4e723bcc4d33ad47077aca01edca0f6
https://github.com/openshift/openshift-restclient-python/blob/5d86bf5ba4e723bcc4d33ad47077aca01edca0f6/openshift/dynamic/client.py#L71-L83
247,889
openshift/openshift-restclient-python
openshift/dynamic/client.py
DynamicClient.watch
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 namespace to query :param name: The name of the resource instance to query :param label_selector: The label selector with which to filter results :param field_selector: The field selector with which to filter results :param resource_version: The version with which to filter results. Only events with a resource_version greater than this value will be returned :param timeout: The amount of time in seconds to wait before terminating the stream :return: Event object with these keys: 'type': The type of event such as "ADDED", "DELETED", etc. 'raw_object': a dict representing the watched object. 'object': A ResourceInstance wrapping raw_object. Example: client = DynamicClient(k8s_client) v1_pods = client.resources.get(api_version='v1', kind='Pod') for e in v1_pods.watch(resource_version=0, namespace=default, timeout=5): print(e['type']) print(e['object'].metadata) """ watcher = watch.Watch() for event in watcher.stream( resource.get, namespace=namespace, name=name, field_selector=field_selector, label_selector=label_selector, resource_version=resource_version, serialize=False, timeout_seconds=timeout ): event['object'] = ResourceInstance(resource, event['object']) yield event
python
def watch(self, resource, namespace=None, name=None, label_selector=None, field_selector=None, resource_version=None, timeout=None): watcher = watch.Watch() for event in watcher.stream( resource.get, namespace=namespace, name=name, field_selector=field_selector, label_selector=label_selector, resource_version=resource_version, serialize=False, timeout_seconds=timeout ): event['object'] = ResourceInstance(resource, event['object']) yield event
[ "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 namespace to query :param name: The name of the resource instance to query :param label_selector: The label selector with which to filter results :param field_selector: The field selector with which to filter results :param resource_version: The version with which to filter results. Only events with a resource_version greater than this value will be returned :param timeout: The amount of time in seconds to wait before terminating the stream :return: Event object with these keys: 'type': The type of event such as "ADDED", "DELETED", etc. 'raw_object': a dict representing the watched object. 'object': A ResourceInstance wrapping raw_object. Example: client = DynamicClient(k8s_client) v1_pods = client.resources.get(api_version='v1', kind='Pod') for e in v1_pods.watch(resource_version=0, namespace=default, timeout=5): print(e['type']) print(e['object'].metadata)
[ "Stream", "events", "for", "a", "resource", "from", "the", "Kubernetes", "API" ]
5d86bf5ba4e723bcc4d33ad47077aca01edca0f6
https://github.com/openshift/openshift-restclient-python/blob/5d86bf5ba4e723bcc4d33ad47077aca01edca0f6/openshift/dynamic/client.py#L179-L217
247,890
openshift/openshift-restclient-python
openshift/dynamic/client.py
DynamicClient.validate
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 properties should be considered errors Returns: warnings (list), errors (list): warnings are missing validations, errors are validation failures """ if not HAS_KUBERNETES_VALIDATE: raise KubernetesValidateMissing() errors = list() warnings = list() try: if version is None: try: version = self.version['kubernetes']['gitVersion'] except KeyError: version = kubernetes_validate.latest_version() kubernetes_validate.validate(definition, version, strict) except kubernetes_validate.utils.ValidationError as e: errors.append("resource definition validation error at %s: %s" % ('.'.join([str(item) for item in e.path]), e.message)) # noqa: B306 except VersionNotSupportedError as e: errors.append("Kubernetes version %s is not supported by kubernetes-validate" % version) except kubernetes_validate.utils.SchemaNotFoundError as e: warnings.append("Could not find schema for object kind %s with API version %s in Kubernetes version %s (possibly Custom Resource?)" % (e.kind, e.api_version, e.version)) return warnings, errors
python
def validate(self, definition, version=None, strict=False): if not HAS_KUBERNETES_VALIDATE: raise KubernetesValidateMissing() errors = list() warnings = list() try: if version is None: try: version = self.version['kubernetes']['gitVersion'] except KeyError: version = kubernetes_validate.latest_version() kubernetes_validate.validate(definition, version, strict) except kubernetes_validate.utils.ValidationError as e: errors.append("resource definition validation error at %s: %s" % ('.'.join([str(item) for item in e.path]), e.message)) # noqa: B306 except VersionNotSupportedError as e: errors.append("Kubernetes version %s is not supported by kubernetes-validate" % version) except kubernetes_validate.utils.SchemaNotFoundError as e: warnings.append("Could not find schema for object kind %s with API version %s in Kubernetes version %s (possibly Custom Resource?)" % (e.kind, e.api_version, e.version)) return warnings, errors
[ "def", "validate", "(", "self", ",", "definition", ",", "version", "=", "None", ",", "strict", "=", "False", ")", ":", "if", "not", "HAS_KUBERNETES_VALIDATE", ":", "raise", "KubernetesValidateMissing", "(", ")", "errors", "=", "list", "(", ")", "warnings", ...
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 (list), errors (list): warnings are missing validations, errors are validation failures
[ "validate", "checks", "a", "kubernetes", "resource", "definition" ]
5d86bf5ba4e723bcc4d33ad47077aca01edca0f6
https://github.com/openshift/openshift-restclient-python/blob/5d86bf5ba4e723bcc4d33ad47077aca01edca0f6/openshift/dynamic/client.py#L278-L308
247,891
openshift/openshift-restclient-python
openshift/dynamic/client.py
Discoverer.parse_api_groups
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('GET', '/{}'.format(DISCOVERY_PREFIX)))['groups'] groups = self.default_groups(request_resources=request_resources) for group in groups_response: new_group = {} for version_raw in group['versions']: version = version_raw['version'] resource_group = self._cache.get('resources', {}).get(DISCOVERY_PREFIX, {}).get(group['name'], {}).get(version) preferred = version_raw == group['preferredVersion'] resources = resource_group.resources if resource_group else {} if request_resources: resources = self.get_resources_for_api_version(DISCOVERY_PREFIX, group['name'], version, preferred) new_group[version] = ResourceGroup(preferred, resources=resources) groups[DISCOVERY_PREFIX][group['name']] = new_group self._cache['resources'].update(groups) self._write_cache() return self._cache['resources']
python
def parse_api_groups(self, request_resources=False, update=False): if not self._cache.get('resources') or update: self._cache['resources'] = self._cache.get('resources', {}) groups_response = load_json(self.client.request('GET', '/{}'.format(DISCOVERY_PREFIX)))['groups'] groups = self.default_groups(request_resources=request_resources) for group in groups_response: new_group = {} for version_raw in group['versions']: version = version_raw['version'] resource_group = self._cache.get('resources', {}).get(DISCOVERY_PREFIX, {}).get(group['name'], {}).get(version) preferred = version_raw == group['preferredVersion'] resources = resource_group.resources if resource_group else {} if request_resources: resources = self.get_resources_for_api_version(DISCOVERY_PREFIX, group['name'], version, preferred) new_group[version] = ResourceGroup(preferred, resources=resources) groups[DISCOVERY_PREFIX][group['name']] = new_group self._cache['resources'].update(groups) self._write_cache() return self._cache['resources']
[ "def", "parse_api_groups", "(", "self", ",", "request_resources", "=", "False", ",", "update", "=", "False", ")", ":", "if", "not", "self", ".", "_cache", ".", "get", "(", "'resources'", ")", "or", "update", ":", "self", ".", "_cache", "[", "'resources'"...
Discovers all API groups present in the cluster
[ "Discovers", "all", "API", "groups", "present", "in", "the", "cluster" ]
5d86bf5ba4e723bcc4d33ad47077aca01edca0f6
https://github.com/openshift/openshift-restclient-python/blob/5d86bf5ba4e723bcc4d33ad47077aca01edca0f6/openshift/dynamic/client.py#L656-L678
247,892
openshift/openshift-restclient-python
openshift/dynamic/client.py
Discoverer.get
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 are multiple matches, prefer exact matches on api_version if len(results) > 1 and kwargs.get('api_version'): results = [ result for result in results if result.group_version == kwargs['api_version'] ] # If there are multiple matches, prefer non-List kinds if len(results) > 1 and not all([isinstance(x, ResourceList) for x in results]): results = [result for result in results if not isinstance(result, ResourceList)] if len(results) == 1: return results[0] elif not results: raise ResourceNotFoundError('No matches found for {}'.format(kwargs)) else: raise ResourceNotUniqueError('Multiple matches found for {}: {}'.format(kwargs, results))
python
def get(self, **kwargs): results = self.search(**kwargs) # If there are multiple matches, prefer exact matches on api_version if len(results) > 1 and kwargs.get('api_version'): results = [ result for result in results if result.group_version == kwargs['api_version'] ] # If there are multiple matches, prefer non-List kinds if len(results) > 1 and not all([isinstance(x, ResourceList) for x in results]): results = [result for result in results if not isinstance(result, ResourceList)] if len(results) == 1: return results[0] elif not results: raise ResourceNotFoundError('No matches found for {}'.format(kwargs)) else: raise ResourceNotUniqueError('Multiple matches found for {}: {}'.format(kwargs, results))
[ "def", "get", "(", "self", ",", "*", "*", "kwargs", ")", ":", "results", "=", "self", ".", "search", "(", "*", "*", "kwargs", ")", "# If there are multiple matches, prefer exact matches on api_version", "if", "len", "(", "results", ")", ">", "1", "and", "kwa...
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.
[ "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", "re...
5d86bf5ba4e723bcc4d33ad47077aca01edca0f6
https://github.com/openshift/openshift-restclient-python/blob/5d86bf5ba4e723bcc4d33ad47077aca01edca0f6/openshift/dynamic/client.py#L735-L754
247,893
dhylands/rshell
rshell/main.py
add_device
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. Delete the old one if test_dev is DEFAULT_DEV: DEFAULT_DEV = None del DEVS[idx] break if find_device_by_name(dev.name): # This name is taken - make it unique dev.name += '-%d' % DEV_IDX dev.name_path = '/' + dev.name + '/' DEVS.append(dev) DEV_IDX += 1 if DEFAULT_DEV is None: DEFAULT_DEV = dev
python
def add_device(dev): 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. Delete the old one if test_dev is DEFAULT_DEV: DEFAULT_DEV = None del DEVS[idx] break if find_device_by_name(dev.name): # This name is taken - make it unique dev.name += '-%d' % DEV_IDX dev.name_path = '/' + dev.name + '/' DEVS.append(dev) DEV_IDX += 1 if DEFAULT_DEV is None: DEFAULT_DEV = dev
[ "def", "add_device", "(", "dev", ")", ":", "global", "DEV_IDX", ",", "DEFAULT_DEV", "with", "DEV_LOCK", ":", "for", "idx", "in", "range", "(", "len", "(", "DEVS", ")", ")", ":", "test_dev", "=", "DEVS", "[", "idx", "]", "if", "test_dev", ".", "dev_na...
Adds a device to the list of devices we know about.
[ "Adds", "a", "device", "to", "the", "list", "of", "devices", "we", "know", "about", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L176-L195
247,894
dhylands/rshell
rshell/main.py
find_device_by_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
python
def find_device_by_name(name): if not name: return DEFAULT_DEV with DEV_LOCK: for dev in DEVS: if dev.name == name: return dev return None
[ "def", "find_device_by_name", "(", "name", ")", ":", "if", "not", "name", ":", "return", "DEFAULT_DEV", "with", "DEV_LOCK", ":", "for", "dev", "in", "DEVS", ":", "if", "dev", ".", "name", "==", "name", ":", "return", "dev", "return", "None" ]
Tries to find a board by board name.
[ "Tries", "to", "find", "a", "board", "by", "board", "name", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L198-L206
247,895
dhylands/rshell
rshell/main.py
is_micropython_usb_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'] != 'tty'): return False usb_id = 'usb vid:pid={}:{}'.format(port['ID_VENDOR_ID'], port['ID_MODEL_ID']) else: # Assume its a port from serial.tools.list_ports.comports() usb_id = port[2].lower() # We don't check the last digit of the PID since there are 3 possible # values. if usb_id.startswith('usb vid:pid=f055:980'): return True # Check for Teensy VID:PID if usb_id.startswith('usb vid:pid=16c0:0483'): return True return False
python
def is_micropython_usb_device(port): 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'] != 'tty'): return False usb_id = 'usb vid:pid={}:{}'.format(port['ID_VENDOR_ID'], port['ID_MODEL_ID']) else: # Assume its a port from serial.tools.list_ports.comports() usb_id = port[2].lower() # We don't check the last digit of the PID since there are 3 possible # values. if usb_id.startswith('usb vid:pid=f055:980'): return True # Check for Teensy VID:PID if usb_id.startswith('usb vid:pid=16c0:0483'): return True return False
[ "def", "is_micropython_usb_device", "(", "port", ")", ":", "if", "type", "(", "port", ")", ".", "__name__", "==", "'Device'", ":", "# Assume its a pyudev.device.Device", "if", "(", "'ID_BUS'", "not", "in", "port", "or", "port", "[", "'ID_BUS'", "]", "!=", "'...
Checks a USB device to see if it looks like a MicroPython device.
[ "Checks", "a", "USB", "device", "to", "see", "if", "it", "looks", "like", "a", "MicroPython", "device", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L222-L241
247,896
dhylands/rshell
rshell/main.py
is_micropython_usb_port
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
python
def is_micropython_usb_port(portName): for port in serial.tools.list_ports.comports(): if port.device == portName: return is_micropython_usb_device(port) return False
[ "def", "is_micropython_usb_port", "(", "portName", ")", ":", "for", "port", "in", "serial", ".", "tools", ".", "list_ports", ".", "comports", "(", ")", ":", "if", "port", ".", "device", "==", "portName", ":", "return", "is_micropython_usb_device", "(", "port...
Checks to see if the indicated portname is a MicroPython device or not.
[ "Checks", "to", "see", "if", "the", "indicated", "portname", "is", "a", "MicroPython", "device", "or", "not", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L244-L251
247,897
dhylands/rshell
rshell/main.py
autoconnect
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 context = pyudev.Context() monitor = pyudev.Monitor.from_netlink(context) connect_thread = threading.Thread(target=autoconnect_thread, args=(monitor,), name='AutoConnect') connect_thread.daemon = True connect_thread.start()
python
def autoconnect(): if not USE_AUTOCONNECT: return try: import pyudev except ImportError: return context = pyudev.Context() monitor = pyudev.Monitor.from_netlink(context) connect_thread = threading.Thread(target=autoconnect_thread, args=(monitor,), name='AutoConnect') connect_thread.daemon = True connect_thread.start()
[ "def", "autoconnect", "(", ")", ":", "if", "not", "USE_AUTOCONNECT", ":", "return", "try", ":", "import", "pyudev", "except", "ImportError", ":", "return", "context", "=", "pyudev", ".", "Context", "(", ")", "monitor", "=", "pyudev", ".", "Monitor", ".", ...
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.
[ "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", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L254-L269
247,898
dhylands/rshell
rshell/main.py
autoconnect_thread
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 InterruptedError: continue for fileno, _ in events: if fileno == monitor.fileno(): usb_dev = monitor.poll() print('autoconnect: {} action: {}'.format(usb_dev.device_node, usb_dev.action)) dev = find_serial_device_by_port(usb_dev.device_node) if usb_dev.action == 'add': # Try connecting a few times. Sometimes the serial port # reports itself as busy, which causes the connection to fail. for i in range(8): if dev: connected = connect_serial(dev.port, dev.baud, dev.wait) elif is_micropython_usb_device(usb_dev): connected = connect_serial(usb_dev.device_node) else: connected = False if connected: break time.sleep(0.25) elif usb_dev.action == 'remove': print('') print("USB Serial device '%s' disconnected" % usb_dev.device_node) if dev: dev.close() break
python
def autoconnect_thread(monitor): monitor.start() monitor.filter_by('tty') epoll = select.epoll() epoll.register(monitor.fileno(), select.POLLIN) while True: try: events = epoll.poll() except InterruptedError: continue for fileno, _ in events: if fileno == monitor.fileno(): usb_dev = monitor.poll() print('autoconnect: {} action: {}'.format(usb_dev.device_node, usb_dev.action)) dev = find_serial_device_by_port(usb_dev.device_node) if usb_dev.action == 'add': # Try connecting a few times. Sometimes the serial port # reports itself as busy, which causes the connection to fail. for i in range(8): if dev: connected = connect_serial(dev.port, dev.baud, dev.wait) elif is_micropython_usb_device(usb_dev): connected = connect_serial(usb_dev.device_node) else: connected = False if connected: break time.sleep(0.25) elif usb_dev.action == 'remove': print('') print("USB Serial device '%s' disconnected" % usb_dev.device_node) if dev: dev.close() break
[ "def", "autoconnect_thread", "(", "monitor", ")", ":", "monitor", ".", "start", "(", ")", "monitor", ".", "filter_by", "(", "'tty'", ")", "epoll", "=", "select", ".", "epoll", "(", ")", "epoll", ".", "register", "(", "monitor", ".", "fileno", "(", ")",...
Thread which detects USB Serial devices connecting and disconnecting.
[ "Thread", "which", "detects", "USB", "Serial", "devices", "connecting", "and", "disconnecting", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L272-L308
247,899
dhylands/rshell
rshell/main.py
extra_info
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(port.serial_number)) if port.interface: extra_items.append("intf '{}'".format(port.interface)) if extra_items: return ' with ' + ' '.join(extra_items) return ''
python
def extra_info(port): extra_items = [] if port.manufacturer: extra_items.append("vendor '{}'".format(port.manufacturer)) if port.serial_number: extra_items.append("serial '{}'".format(port.serial_number)) if port.interface: extra_items.append("intf '{}'".format(port.interface)) if extra_items: return ' with ' + ' '.join(extra_items) return ''
[ "def", "extra_info", "(", "port", ")", ":", "extra_items", "=", "[", "]", "if", "port", ".", "manufacturer", ":", "extra_items", ".", "append", "(", "\"vendor '{}'\"", ".", "format", "(", "port", ".", "manufacturer", ")", ")", "if", "port", ".", "serial_...
Collects the serial nunber and manufacturer into a string, if the fields are available.
[ "Collects", "the", "serial", "nunber", "and", "manufacturer", "into", "a", "string", "if", "the", "fields", "are", "available", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L320-L332