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
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
234,000
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): """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
[ "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" ]
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
234,001
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): """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)
[ "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", ")" ]
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
234,002
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): """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)
[ "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", ")" ]
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
234,003
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): """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)
[ "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", ")" ]
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
234,004
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): """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]
[ "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", "]" ]
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
234,005
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): """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
[ "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" ]
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
234,006
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): """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)
[ "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
234,007
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): """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)
[ "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
234,008
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): """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)
[ "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", ")" ]
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
234,009
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): """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
[ "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" ]
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
234,010
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): """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
[ "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" ]
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
234,011
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): """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
[ "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" ]
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
234,012
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): """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
[ "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" ]
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
234,013
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): """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
[ "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" ]
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
234,014
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): """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
[ "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" ]
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
234,015
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): """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)
[ "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
234,016
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): """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
[ "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" ]
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
234,017
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): """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
[ "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" ]
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
234,018
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): """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
[ "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" ]
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
234,019
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): """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
[ "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" ]
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
234,020
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): """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
[ "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" ]
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
234,021
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): """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
[ "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" ]
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
234,022
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): """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)
[ "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", ")" ]
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
234,023
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): """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)
[ "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", ")" ]
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
234,024
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): """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)
[ "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", ")" ]
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
234,025
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): """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
[ "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
234,026
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): """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)
[ "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", ")" ]
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
234,027
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): """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)
[ "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", ")" ]
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
234,028
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): """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)
[ "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", ")" ]
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
234,029
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): """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)
[ "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", ")" ]
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
234,030
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): """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
[ "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" ]
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
234,031
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): """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)
[ "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", ")" ]
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
234,032
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): """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
[ "def", "peek_8", "(", "library", ",", "session", ",", "address", ")", ":", "value_8", "=", "ViUInt8", "(", ")", "ret", "=", "library", ".", "viPeek8", "(", "session", ",", "address", ",", "byref", "(", "value_8", ")", ")", "return", "value_8", ".", "value", ",", "ret" ]
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
234,033
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): """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
[ "def", "peek_16", "(", "library", ",", "session", ",", "address", ")", ":", "value_16", "=", "ViUInt16", "(", ")", "ret", "=", "library", ".", "viPeek16", "(", "session", ",", "address", ",", "byref", "(", "value_16", ")", ")", "return", "value_16", ".", "value", ",", "ret" ]
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
234,034
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): """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
[ "def", "peek_32", "(", "library", ",", "session", ",", "address", ")", ":", "value_32", "=", "ViUInt32", "(", ")", "ret", "=", "library", ".", "viPeek32", "(", "session", ",", "address", ",", "byref", "(", "value_32", ")", ")", "return", "value_32", ".", "value", ",", "ret" ]
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
234,035
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): """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
[ "def", "peek_64", "(", "library", ",", "session", ",", "address", ")", ":", "value_64", "=", "ViUInt64", "(", ")", "ret", "=", "library", ".", "viPeek64", "(", "session", ",", "address", ",", "byref", "(", "value_64", ")", ")", "return", "value_64", ".", "value", ",", "ret" ]
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
234,036
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): """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)
[ "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", ")" ]
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
234,037
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): """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)
[ "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
234,038
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): """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)
[ "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
234,039
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): """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)
[ "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
234,040
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): """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)
[ "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
234,041
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): """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
[ "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" ]
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
234,042
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): """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
[ "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
234,043
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): """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
[ "def", "read_to_file", "(", "library", ",", "session", ",", "filename", ",", "count", ")", ":", "return_count", "=", "ViUInt32", "(", ")", "ret", "=", "library", ".", "viReadToFile", "(", "session", ",", "filename", ",", "count", ",", "return_count", ")", "return", "return_count", ",", "ret" ]
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
234,044
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): """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
[ "def", "status_description", "(", "library", ",", "session", ",", "status", ")", ":", "description", "=", "create_string_buffer", "(", "256", ")", "ret", "=", "library", ".", "viStatusDesc", "(", "session", ",", "status", ",", "description", ")", "return", "buffer_to_text", "(", "description", ")", ",", "ret" ]
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
234,045
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): """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)
[ "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
234,046
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): """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)
[ "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
234,047
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): """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
[ "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" ]
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
234,048
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=""): """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)
[ "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", ")" ]
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
234,049
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): """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
[ "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" ]
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
234,050
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): """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
[ "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" ]
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
234,051
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): """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
[ "def", "write_from_file", "(", "library", ",", "session", ",", "filename", ",", "count", ")", ":", "return_count", "=", "ViUInt32", "(", ")", "ret", "=", "library", ".", "viWriteFromFile", "(", "session", ",", "filename", ",", "count", ",", "return_count", ")", "return", "return_count", ",", "ret" ]
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
234,052
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): """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
[ "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
234,053
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): """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))
[ "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", ")", ")" ]
List all connected resources.
[ "List", "all", "connected", "resources", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/shell.py#L121-L136
234,054
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): """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
[ "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" ]
Close resource in use.
[ "Close", "resource", "in", "use", "." ]
b8b2d4371e1f00782856aa9176ff1ced6bcb3798
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/shell.py#L179-L193
234,055
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): """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)
[ "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", ")" ]
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
234,056
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): """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)
[ "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", ")" ]
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
234,057
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): """Exit the shell session.""" 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
234,058
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): """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)
[ "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
234,059
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): """The interface type of the resource as a number. """ 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
234,060
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): """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
[ "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" ]
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
234,061
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): """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)
[ "def", "install_handler", "(", "self", ",", "event_type", ",", "handler", ",", "user_handle", "=", "None", ")", ":", "return", "self", ".", "visalib", ".", "install_visa_handler", "(", "self", ".", "session", ",", "event_type", ",", "handler", ",", "user_handle", ")" ]
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
234,062
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): """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)
[ "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
234,063
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): """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)
[ "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
234,064
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): """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)
[ "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
234,065
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): """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)
[ "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", ")" ]
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
234,066
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): """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]
[ "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", "]" ]
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
234,067
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'): """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)
[ "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", ")" ]
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
234,068
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'): """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()
[ "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", "(", ")" ]
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
234,069
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): """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]
[ "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", "]" ]
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
234,070
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): """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
[ "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" ]
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
234,071
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): """ 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] += "'"
[ "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", "]", "+=", "\"'\"" ]
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
234,072
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): """ 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
[ "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" ]
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
234,073
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): """ 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
[ "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" ]
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
234,074
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): """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
[ "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" ]
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
234,075
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): """ 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']
[ "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'", "]" ]
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
234,076
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): """ 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))
[ "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", ")", ")" ]
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", "resource", "will", "be", "returned", "." ]
5d86bf5ba4e723bcc4d33ad47077aca01edca0f6
https://github.com/openshift/openshift-restclient-python/blob/5d86bf5ba4e723bcc4d33ad47077aca01edca0f6/openshift/dynamic/client.py#L735-L754
234,077
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): """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
[ "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" ]
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
234,078
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): """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
[ "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
234,079
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): """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
[ "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" ]
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
234,080
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): """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
[ "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" ]
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
234,081
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(): """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()
[ "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", "(", ")" ]
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
234,082
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): """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
[ "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" ]
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
234,083
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): """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 ''
[ "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", "''" ]
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
234,084
dhylands/rshell
rshell/main.py
listports
def listports(): """listports will display a list of all of the serial ports. """ detected = False for port in serial.tools.list_ports.comports(): detected = True if port.vid: micropythonPort = '' if is_micropython_usb_device(port): micropythonPort = ' *' print('USB Serial Device {:04x}:{:04x}{} found @{}{}\r'.format( port.vid, port.pid, extra_info(port), port.device, micropythonPort)) else: print('Serial Device:', port.device) if not detected: print('No serial devices detected')
python
def listports(): """listports will display a list of all of the serial ports. """ detected = False for port in serial.tools.list_ports.comports(): detected = True if port.vid: micropythonPort = '' if is_micropython_usb_device(port): micropythonPort = ' *' print('USB Serial Device {:04x}:{:04x}{} found @{}{}\r'.format( port.vid, port.pid, extra_info(port), port.device, micropythonPort)) else: print('Serial Device:', port.device) if not detected: print('No serial devices detected')
[ "def", "listports", "(", ")", ":", "detected", "=", "False", "for", "port", "in", "serial", ".", "tools", ".", "list_ports", ".", "comports", "(", ")", ":", "detected", "=", "True", "if", "port", ".", "vid", ":", "micropythonPort", "=", "''", "if", "is_micropython_usb_device", "(", "port", ")", ":", "micropythonPort", "=", "' *'", "print", "(", "'USB Serial Device {:04x}:{:04x}{} found @{}{}\\r'", ".", "format", "(", "port", ".", "vid", ",", "port", ".", "pid", ",", "extra_info", "(", "port", ")", ",", "port", ".", "device", ",", "micropythonPort", ")", ")", "else", ":", "print", "(", "'Serial Device:'", ",", "port", ".", "device", ")", "if", "not", "detected", ":", "print", "(", "'No serial devices detected'", ")" ]
listports will display a list of all of the serial ports.
[ "listports", "will", "display", "a", "list", "of", "all", "of", "the", "serial", "ports", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L335-L351
234,085
dhylands/rshell
rshell/main.py
escape
def escape(str): """Precede all special characters with a backslash.""" out = '' for char in str: if char in '\\ ': out += '\\' out += char return out
python
def escape(str): """Precede all special characters with a backslash.""" out = '' for char in str: if char in '\\ ': out += '\\' out += char return out
[ "def", "escape", "(", "str", ")", ":", "out", "=", "''", "for", "char", "in", "str", ":", "if", "char", "in", "'\\\\ '", ":", "out", "+=", "'\\\\'", "out", "+=", "char", "return", "out" ]
Precede all special characters with a backslash.
[ "Precede", "all", "special", "characters", "with", "a", "backslash", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L354-L361
234,086
dhylands/rshell
rshell/main.py
align_cell
def align_cell(fmt, elem, width): """Returns an aligned element.""" if fmt == "<": return elem + ' ' * (width - len(elem)) if fmt == ">": return ' ' * (width - len(elem)) + elem return elem
python
def align_cell(fmt, elem, width): """Returns an aligned element.""" if fmt == "<": return elem + ' ' * (width - len(elem)) if fmt == ">": return ' ' * (width - len(elem)) + elem return elem
[ "def", "align_cell", "(", "fmt", ",", "elem", ",", "width", ")", ":", "if", "fmt", "==", "\"<\"", ":", "return", "elem", "+", "' '", "*", "(", "width", "-", "len", "(", "elem", ")", ")", "if", "fmt", "==", "\">\"", ":", "return", "' '", "*", "(", "width", "-", "len", "(", "elem", ")", ")", "+", "elem", "return", "elem" ]
Returns an aligned element.
[ "Returns", "an", "aligned", "element", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L377-L383
234,087
dhylands/rshell
rshell/main.py
print_err
def print_err(*args, end='\n'): """Similar to print, but prints to stderr. """ print(*args, end=end, file=sys.stderr) sys.stderr.flush()
python
def print_err(*args, end='\n'): """Similar to print, but prints to stderr. """ print(*args, end=end, file=sys.stderr) sys.stderr.flush()
[ "def", "print_err", "(", "*", "args", ",", "end", "=", "'\\n'", ")", ":", "print", "(", "*", "args", ",", "end", "=", "end", ",", "file", "=", "sys", ".", "stderr", ")", "sys", ".", "stderr", ".", "flush", "(", ")" ]
Similar to print, but prints to stderr.
[ "Similar", "to", "print", "but", "prints", "to", "stderr", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L421-L425
234,088
dhylands/rshell
rshell/main.py
validate_pattern
def validate_pattern(fn): """On success return an absolute path and a pattern. Otherwise print a message and return None, None """ directory, pattern = parse_pattern(fn) if directory is None: print_err("Invalid pattern {}.".format(fn)) return None, None target = resolve_path(directory) mode = auto(get_mode, target) if not mode_exists(mode): print_err("cannot access '{}': No such file or directory".format(fn)) return None, None if not mode_isdir(mode): print_err("cannot access '{}': Not a directory".format(fn)) return None, None return target, pattern
python
def validate_pattern(fn): """On success return an absolute path and a pattern. Otherwise print a message and return None, None """ directory, pattern = parse_pattern(fn) if directory is None: print_err("Invalid pattern {}.".format(fn)) return None, None target = resolve_path(directory) mode = auto(get_mode, target) if not mode_exists(mode): print_err("cannot access '{}': No such file or directory".format(fn)) return None, None if not mode_isdir(mode): print_err("cannot access '{}': Not a directory".format(fn)) return None, None return target, pattern
[ "def", "validate_pattern", "(", "fn", ")", ":", "directory", ",", "pattern", "=", "parse_pattern", "(", "fn", ")", "if", "directory", "is", "None", ":", "print_err", "(", "\"Invalid pattern {}.\"", ".", "format", "(", "fn", ")", ")", "return", "None", ",", "None", "target", "=", "resolve_path", "(", "directory", ")", "mode", "=", "auto", "(", "get_mode", ",", "target", ")", "if", "not", "mode_exists", "(", "mode", ")", ":", "print_err", "(", "\"cannot access '{}': No such file or directory\"", ".", "format", "(", "fn", ")", ")", "return", "None", ",", "None", "if", "not", "mode_isdir", "(", "mode", ")", ":", "print_err", "(", "\"cannot access '{}': Not a directory\"", ".", "format", "(", "fn", ")", ")", "return", "None", ",", "None", "return", "target", ",", "pattern" ]
On success return an absolute path and a pattern. Otherwise print a message and return None, None
[ "On", "success", "return", "an", "absolute", "path", "and", "a", "pattern", ".", "Otherwise", "print", "a", "message", "and", "return", "None", "None" ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L463-L479
234,089
dhylands/rshell
rshell/main.py
resolve_path
def resolve_path(path): """Resolves path and converts it into an absolute path.""" if path[0] == '~': # ~ or ~user path = os.path.expanduser(path) if path[0] != '/': # Relative path if cur_dir[-1] == '/': path = cur_dir + path else: path = cur_dir + '/' + path comps = path.split('/') new_comps = [] for comp in comps: # We strip out xxx/./xxx and xxx//xxx, except that we want to keep the # leading / for absolute paths. This also removes the trailing slash # that autocompletion adds to a directory. if comp == '.' or (comp == '' and len(new_comps) > 0): continue if comp == '..': if len(new_comps) > 1: new_comps.pop() else: new_comps.append(comp) if len(new_comps) == 1 and new_comps[0] == '': return '/' return '/'.join(new_comps)
python
def resolve_path(path): """Resolves path and converts it into an absolute path.""" if path[0] == '~': # ~ or ~user path = os.path.expanduser(path) if path[0] != '/': # Relative path if cur_dir[-1] == '/': path = cur_dir + path else: path = cur_dir + '/' + path comps = path.split('/') new_comps = [] for comp in comps: # We strip out xxx/./xxx and xxx//xxx, except that we want to keep the # leading / for absolute paths. This also removes the trailing slash # that autocompletion adds to a directory. if comp == '.' or (comp == '' and len(new_comps) > 0): continue if comp == '..': if len(new_comps) > 1: new_comps.pop() else: new_comps.append(comp) if len(new_comps) == 1 and new_comps[0] == '': return '/' return '/'.join(new_comps)
[ "def", "resolve_path", "(", "path", ")", ":", "if", "path", "[", "0", "]", "==", "'~'", ":", "# ~ or ~user", "path", "=", "os", ".", "path", ".", "expanduser", "(", "path", ")", "if", "path", "[", "0", "]", "!=", "'/'", ":", "# Relative path", "if", "cur_dir", "[", "-", "1", "]", "==", "'/'", ":", "path", "=", "cur_dir", "+", "path", "else", ":", "path", "=", "cur_dir", "+", "'/'", "+", "path", "comps", "=", "path", ".", "split", "(", "'/'", ")", "new_comps", "=", "[", "]", "for", "comp", "in", "comps", ":", "# We strip out xxx/./xxx and xxx//xxx, except that we want to keep the", "# leading / for absolute paths. This also removes the trailing slash", "# that autocompletion adds to a directory.", "if", "comp", "==", "'.'", "or", "(", "comp", "==", "''", "and", "len", "(", "new_comps", ")", ">", "0", ")", ":", "continue", "if", "comp", "==", "'..'", ":", "if", "len", "(", "new_comps", ")", ">", "1", ":", "new_comps", ".", "pop", "(", ")", "else", ":", "new_comps", ".", "append", "(", "comp", ")", "if", "len", "(", "new_comps", ")", "==", "1", "and", "new_comps", "[", "0", "]", "==", "''", ":", "return", "'/'", "return", "'/'", ".", "join", "(", "new_comps", ")" ]
Resolves path and converts it into an absolute path.
[ "Resolves", "path", "and", "converts", "it", "into", "an", "absolute", "path", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L494-L520
234,090
dhylands/rshell
rshell/main.py
print_bytes
def print_bytes(byte_str): """Prints a string or converts bytes to a string and then prints.""" if isinstance(byte_str, str): print(byte_str) else: print(str(byte_str, encoding='utf8'))
python
def print_bytes(byte_str): """Prints a string or converts bytes to a string and then prints.""" if isinstance(byte_str, str): print(byte_str) else: print(str(byte_str, encoding='utf8'))
[ "def", "print_bytes", "(", "byte_str", ")", ":", "if", "isinstance", "(", "byte_str", ",", "str", ")", ":", "print", "(", "byte_str", ")", "else", ":", "print", "(", "str", "(", "byte_str", ",", "encoding", "=", "'utf8'", ")", ")" ]
Prints a string or converts bytes to a string and then prints.
[ "Prints", "a", "string", "or", "converts", "bytes", "to", "a", "string", "and", "then", "prints", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L559-L564
234,091
dhylands/rshell
rshell/main.py
extra_funcs
def extra_funcs(*funcs): """Decorator which adds extra functions to be downloaded to the pyboard.""" def extra_funcs_decorator(real_func): def wrapper(*args, **kwargs): return real_func(*args, **kwargs) wrapper.extra_funcs = list(funcs) wrapper.source = inspect.getsource(real_func) wrapper.name = real_func.__name__ return wrapper return extra_funcs_decorator
python
def extra_funcs(*funcs): """Decorator which adds extra functions to be downloaded to the pyboard.""" def extra_funcs_decorator(real_func): def wrapper(*args, **kwargs): return real_func(*args, **kwargs) wrapper.extra_funcs = list(funcs) wrapper.source = inspect.getsource(real_func) wrapper.name = real_func.__name__ return wrapper return extra_funcs_decorator
[ "def", "extra_funcs", "(", "*", "funcs", ")", ":", "def", "extra_funcs_decorator", "(", "real_func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "real_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "wrapper", ".", "extra_funcs", "=", "list", "(", "funcs", ")", "wrapper", ".", "source", "=", "inspect", ".", "getsource", "(", "real_func", ")", "wrapper", ".", "name", "=", "real_func", ".", "__name__", "return", "wrapper", "return", "extra_funcs_decorator" ]
Decorator which adds extra functions to be downloaded to the pyboard.
[ "Decorator", "which", "adds", "extra", "functions", "to", "be", "downloaded", "to", "the", "pyboard", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L567-L576
234,092
dhylands/rshell
rshell/main.py
auto
def auto(func, filename, *args, **kwargs): """If `filename` is a remote file, then this function calls func on the micropython board, otherwise it calls it locally. """ dev, dev_filename = get_dev_and_path(filename) if dev is None: if len(dev_filename) > 0 and dev_filename[0] == '~': dev_filename = os.path.expanduser(dev_filename) return func(dev_filename, *args, **kwargs) return dev.remote_eval(func, dev_filename, *args, **kwargs)
python
def auto(func, filename, *args, **kwargs): """If `filename` is a remote file, then this function calls func on the micropython board, otherwise it calls it locally. """ dev, dev_filename = get_dev_and_path(filename) if dev is None: if len(dev_filename) > 0 and dev_filename[0] == '~': dev_filename = os.path.expanduser(dev_filename) return func(dev_filename, *args, **kwargs) return dev.remote_eval(func, dev_filename, *args, **kwargs)
[ "def", "auto", "(", "func", ",", "filename", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "dev", ",", "dev_filename", "=", "get_dev_and_path", "(", "filename", ")", "if", "dev", "is", "None", ":", "if", "len", "(", "dev_filename", ")", ">", "0", "and", "dev_filename", "[", "0", "]", "==", "'~'", ":", "dev_filename", "=", "os", ".", "path", ".", "expanduser", "(", "dev_filename", ")", "return", "func", "(", "dev_filename", ",", "*", "args", ",", "*", "*", "kwargs", ")", "return", "dev", ".", "remote_eval", "(", "func", ",", "dev_filename", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
If `filename` is a remote file, then this function calls func on the micropython board, otherwise it calls it locally.
[ "If", "filename", "is", "a", "remote", "file", "then", "this", "function", "calls", "func", "on", "the", "micropython", "board", "otherwise", "it", "calls", "it", "locally", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L579-L588
234,093
dhylands/rshell
rshell/main.py
cat
def cat(src_filename, dst_file): """Copies the contents of the indicated file to an already opened file.""" (dev, dev_filename) = get_dev_and_path(src_filename) if dev is None: with open(dev_filename, 'rb') as txtfile: for line in txtfile: dst_file.write(line) else: filesize = dev.remote_eval(get_filesize, dev_filename) return dev.remote(send_file_to_host, dev_filename, dst_file, filesize, xfer_func=recv_file_from_remote)
python
def cat(src_filename, dst_file): """Copies the contents of the indicated file to an already opened file.""" (dev, dev_filename) = get_dev_and_path(src_filename) if dev is None: with open(dev_filename, 'rb') as txtfile: for line in txtfile: dst_file.write(line) else: filesize = dev.remote_eval(get_filesize, dev_filename) return dev.remote(send_file_to_host, dev_filename, dst_file, filesize, xfer_func=recv_file_from_remote)
[ "def", "cat", "(", "src_filename", ",", "dst_file", ")", ":", "(", "dev", ",", "dev_filename", ")", "=", "get_dev_and_path", "(", "src_filename", ")", "if", "dev", "is", "None", ":", "with", "open", "(", "dev_filename", ",", "'rb'", ")", "as", "txtfile", ":", "for", "line", "in", "txtfile", ":", "dst_file", ".", "write", "(", "line", ")", "else", ":", "filesize", "=", "dev", ".", "remote_eval", "(", "get_filesize", ",", "dev_filename", ")", "return", "dev", ".", "remote", "(", "send_file_to_host", ",", "dev_filename", ",", "dst_file", ",", "filesize", ",", "xfer_func", "=", "recv_file_from_remote", ")" ]
Copies the contents of the indicated file to an already opened file.
[ "Copies", "the", "contents", "of", "the", "indicated", "file", "to", "an", "already", "opened", "file", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L612-L622
234,094
dhylands/rshell
rshell/main.py
copy_file
def copy_file(src_filename, dst_filename): """Copies a file from one place to another. Both the source and destination files must exist on the same machine. """ try: with open(src_filename, 'rb') as src_file: with open(dst_filename, 'wb') as dst_file: while True: buf = src_file.read(BUFFER_SIZE) if len(buf) > 0: dst_file.write(buf) if len(buf) < BUFFER_SIZE: break return True except: return False
python
def copy_file(src_filename, dst_filename): """Copies a file from one place to another. Both the source and destination files must exist on the same machine. """ try: with open(src_filename, 'rb') as src_file: with open(dst_filename, 'wb') as dst_file: while True: buf = src_file.read(BUFFER_SIZE) if len(buf) > 0: dst_file.write(buf) if len(buf) < BUFFER_SIZE: break return True except: return False
[ "def", "copy_file", "(", "src_filename", ",", "dst_filename", ")", ":", "try", ":", "with", "open", "(", "src_filename", ",", "'rb'", ")", "as", "src_file", ":", "with", "open", "(", "dst_filename", ",", "'wb'", ")", "as", "dst_file", ":", "while", "True", ":", "buf", "=", "src_file", ".", "read", "(", "BUFFER_SIZE", ")", "if", "len", "(", "buf", ")", ">", "0", ":", "dst_file", ".", "write", "(", "buf", ")", "if", "len", "(", "buf", ")", "<", "BUFFER_SIZE", ":", "break", "return", "True", "except", ":", "return", "False" ]
Copies a file from one place to another. Both the source and destination files must exist on the same machine.
[ "Copies", "a", "file", "from", "one", "place", "to", "another", ".", "Both", "the", "source", "and", "destination", "files", "must", "exist", "on", "the", "same", "machine", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L631-L646
234,095
dhylands/rshell
rshell/main.py
cp
def cp(src_filename, dst_filename): """Copies one file to another. The source file may be local or remote and the destination file may be local or remote. """ src_dev, src_dev_filename = get_dev_and_path(src_filename) dst_dev, dst_dev_filename = get_dev_and_path(dst_filename) if src_dev is dst_dev: # src and dst are either on the same remote, or both are on the host return auto(copy_file, src_filename, dst_dev_filename) filesize = auto(get_filesize, src_filename) if dst_dev is None: # Copying from remote to host with open(dst_dev_filename, 'wb') as dst_file: return src_dev.remote(send_file_to_host, src_dev_filename, dst_file, filesize, xfer_func=recv_file_from_remote) if src_dev is None: # Copying from host to remote with open(src_dev_filename, 'rb') as src_file: return dst_dev.remote(recv_file_from_host, src_file, dst_dev_filename, filesize, xfer_func=send_file_to_remote) # Copying from remote A to remote B. We first copy the file # from remote A to the host and then from the host to remote B host_temp_file = tempfile.TemporaryFile() if src_dev.remote(send_file_to_host, src_dev_filename, host_temp_file, filesize, xfer_func=recv_file_from_remote): host_temp_file.seek(0) return dst_dev.remote(recv_file_from_host, host_temp_file, dst_dev_filename, filesize, xfer_func=send_file_to_remote) return False
python
def cp(src_filename, dst_filename): """Copies one file to another. The source file may be local or remote and the destination file may be local or remote. """ src_dev, src_dev_filename = get_dev_and_path(src_filename) dst_dev, dst_dev_filename = get_dev_and_path(dst_filename) if src_dev is dst_dev: # src and dst are either on the same remote, or both are on the host return auto(copy_file, src_filename, dst_dev_filename) filesize = auto(get_filesize, src_filename) if dst_dev is None: # Copying from remote to host with open(dst_dev_filename, 'wb') as dst_file: return src_dev.remote(send_file_to_host, src_dev_filename, dst_file, filesize, xfer_func=recv_file_from_remote) if src_dev is None: # Copying from host to remote with open(src_dev_filename, 'rb') as src_file: return dst_dev.remote(recv_file_from_host, src_file, dst_dev_filename, filesize, xfer_func=send_file_to_remote) # Copying from remote A to remote B. We first copy the file # from remote A to the host and then from the host to remote B host_temp_file = tempfile.TemporaryFile() if src_dev.remote(send_file_to_host, src_dev_filename, host_temp_file, filesize, xfer_func=recv_file_from_remote): host_temp_file.seek(0) return dst_dev.remote(recv_file_from_host, host_temp_file, dst_dev_filename, filesize, xfer_func=send_file_to_remote) return False
[ "def", "cp", "(", "src_filename", ",", "dst_filename", ")", ":", "src_dev", ",", "src_dev_filename", "=", "get_dev_and_path", "(", "src_filename", ")", "dst_dev", ",", "dst_dev_filename", "=", "get_dev_and_path", "(", "dst_filename", ")", "if", "src_dev", "is", "dst_dev", ":", "# src and dst are either on the same remote, or both are on the host", "return", "auto", "(", "copy_file", ",", "src_filename", ",", "dst_dev_filename", ")", "filesize", "=", "auto", "(", "get_filesize", ",", "src_filename", ")", "if", "dst_dev", "is", "None", ":", "# Copying from remote to host", "with", "open", "(", "dst_dev_filename", ",", "'wb'", ")", "as", "dst_file", ":", "return", "src_dev", ".", "remote", "(", "send_file_to_host", ",", "src_dev_filename", ",", "dst_file", ",", "filesize", ",", "xfer_func", "=", "recv_file_from_remote", ")", "if", "src_dev", "is", "None", ":", "# Copying from host to remote", "with", "open", "(", "src_dev_filename", ",", "'rb'", ")", "as", "src_file", ":", "return", "dst_dev", ".", "remote", "(", "recv_file_from_host", ",", "src_file", ",", "dst_dev_filename", ",", "filesize", ",", "xfer_func", "=", "send_file_to_remote", ")", "# Copying from remote A to remote B. We first copy the file", "# from remote A to the host and then from the host to remote B", "host_temp_file", "=", "tempfile", ".", "TemporaryFile", "(", ")", "if", "src_dev", ".", "remote", "(", "send_file_to_host", ",", "src_dev_filename", ",", "host_temp_file", ",", "filesize", ",", "xfer_func", "=", "recv_file_from_remote", ")", ":", "host_temp_file", ".", "seek", "(", "0", ")", "return", "dst_dev", ".", "remote", "(", "recv_file_from_host", ",", "host_temp_file", ",", "dst_dev_filename", ",", "filesize", ",", "xfer_func", "=", "send_file_to_remote", ")", "return", "False" ]
Copies one file to another. The source file may be local or remote and the destination file may be local or remote.
[ "Copies", "one", "file", "to", "another", ".", "The", "source", "file", "may", "be", "local", "or", "remote", "and", "the", "destination", "file", "may", "be", "local", "or", "remote", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L649-L680
234,096
dhylands/rshell
rshell/main.py
stat
def stat(filename): """Returns os.stat for a given file, adjusting the timestamps as appropriate.""" import os try: # on the host, lstat won't try to follow symlinks rstat = os.lstat(filename) except: rstat = os.stat(filename) return rstat[:7] + tuple(tim + TIME_OFFSET for tim in rstat[7:])
python
def stat(filename): """Returns os.stat for a given file, adjusting the timestamps as appropriate.""" import os try: # on the host, lstat won't try to follow symlinks rstat = os.lstat(filename) except: rstat = os.stat(filename) return rstat[:7] + tuple(tim + TIME_OFFSET for tim in rstat[7:])
[ "def", "stat", "(", "filename", ")", ":", "import", "os", "try", ":", "# on the host, lstat won't try to follow symlinks", "rstat", "=", "os", ".", "lstat", "(", "filename", ")", "except", ":", "rstat", "=", "os", ".", "stat", "(", "filename", ")", "return", "rstat", "[", ":", "7", "]", "+", "tuple", "(", "tim", "+", "TIME_OFFSET", "for", "tim", "in", "rstat", "[", "7", ":", "]", ")" ]
Returns os.stat for a given file, adjusting the timestamps as appropriate.
[ "Returns", "os", ".", "stat", "for", "a", "given", "file", "adjusting", "the", "timestamps", "as", "appropriate", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L713-L721
234,097
dhylands/rshell
rshell/main.py
listdir_matches
def listdir_matches(match): """Returns a list of filenames contained in the named directory. Only filenames which start with `match` will be returned. Directories will have a trailing slash. """ import os last_slash = match.rfind('/') if last_slash == -1: dirname = '.' match_prefix = match result_prefix = '' else: match_prefix = match[last_slash + 1:] if last_slash == 0: dirname = '/' result_prefix = '/' else: dirname = match[0:last_slash] result_prefix = dirname + '/' def add_suffix_if_dir(filename): try: if (os.stat(filename)[0] & 0x4000) != 0: return filename + '/' except FileNotFoundError: # This can happen when a symlink points to a non-existant file. pass return filename matches = [add_suffix_if_dir(result_prefix + filename) for filename in os.listdir(dirname) if filename.startswith(match_prefix)] return matches
python
def listdir_matches(match): """Returns a list of filenames contained in the named directory. Only filenames which start with `match` will be returned. Directories will have a trailing slash. """ import os last_slash = match.rfind('/') if last_slash == -1: dirname = '.' match_prefix = match result_prefix = '' else: match_prefix = match[last_slash + 1:] if last_slash == 0: dirname = '/' result_prefix = '/' else: dirname = match[0:last_slash] result_prefix = dirname + '/' def add_suffix_if_dir(filename): try: if (os.stat(filename)[0] & 0x4000) != 0: return filename + '/' except FileNotFoundError: # This can happen when a symlink points to a non-existant file. pass return filename matches = [add_suffix_if_dir(result_prefix + filename) for filename in os.listdir(dirname) if filename.startswith(match_prefix)] return matches
[ "def", "listdir_matches", "(", "match", ")", ":", "import", "os", "last_slash", "=", "match", ".", "rfind", "(", "'/'", ")", "if", "last_slash", "==", "-", "1", ":", "dirname", "=", "'.'", "match_prefix", "=", "match", "result_prefix", "=", "''", "else", ":", "match_prefix", "=", "match", "[", "last_slash", "+", "1", ":", "]", "if", "last_slash", "==", "0", ":", "dirname", "=", "'/'", "result_prefix", "=", "'/'", "else", ":", "dirname", "=", "match", "[", "0", ":", "last_slash", "]", "result_prefix", "=", "dirname", "+", "'/'", "def", "add_suffix_if_dir", "(", "filename", ")", ":", "try", ":", "if", "(", "os", ".", "stat", "(", "filename", ")", "[", "0", "]", "&", "0x4000", ")", "!=", "0", ":", "return", "filename", "+", "'/'", "except", "FileNotFoundError", ":", "# This can happen when a symlink points to a non-existant file.", "pass", "return", "filename", "matches", "=", "[", "add_suffix_if_dir", "(", "result_prefix", "+", "filename", ")", "for", "filename", "in", "os", ".", "listdir", "(", "dirname", ")", "if", "filename", ".", "startswith", "(", "match_prefix", ")", "]", "return", "matches" ]
Returns a list of filenames contained in the named directory. Only filenames which start with `match` will be returned. Directories will have a trailing slash.
[ "Returns", "a", "list", "of", "filenames", "contained", "in", "the", "named", "directory", ".", "Only", "filenames", "which", "start", "with", "match", "will", "be", "returned", ".", "Directories", "will", "have", "a", "trailing", "slash", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L746-L775
234,098
dhylands/rshell
rshell/main.py
listdir_stat
def listdir_stat(dirname, show_hidden=True): """Returns a list of tuples for each file contained in the named directory, or None if the directory does not exist. Each tuple contains the filename, followed by the tuple returned by calling os.stat on the filename. """ import os try: files = os.listdir(dirname) except OSError: return None if dirname == '/': return list((file, stat('/' + file)) for file in files if is_visible(file) or show_hidden) return list((file, stat(dirname + '/' + file)) for file in files if is_visible(file) or show_hidden)
python
def listdir_stat(dirname, show_hidden=True): """Returns a list of tuples for each file contained in the named directory, or None if the directory does not exist. Each tuple contains the filename, followed by the tuple returned by calling os.stat on the filename. """ import os try: files = os.listdir(dirname) except OSError: return None if dirname == '/': return list((file, stat('/' + file)) for file in files if is_visible(file) or show_hidden) return list((file, stat(dirname + '/' + file)) for file in files if is_visible(file) or show_hidden)
[ "def", "listdir_stat", "(", "dirname", ",", "show_hidden", "=", "True", ")", ":", "import", "os", "try", ":", "files", "=", "os", ".", "listdir", "(", "dirname", ")", "except", "OSError", ":", "return", "None", "if", "dirname", "==", "'/'", ":", "return", "list", "(", "(", "file", ",", "stat", "(", "'/'", "+", "file", ")", ")", "for", "file", "in", "files", "if", "is_visible", "(", "file", ")", "or", "show_hidden", ")", "return", "list", "(", "(", "file", ",", "stat", "(", "dirname", "+", "'/'", "+", "file", ")", ")", "for", "file", "in", "files", "if", "is_visible", "(", "file", ")", "or", "show_hidden", ")" ]
Returns a list of tuples for each file contained in the named directory, or None if the directory does not exist. Each tuple contains the filename, followed by the tuple returned by calling os.stat on the filename.
[ "Returns", "a", "list", "of", "tuples", "for", "each", "file", "contained", "in", "the", "named", "directory", "or", "None", "if", "the", "directory", "does", "not", "exist", ".", "Each", "tuple", "contains", "the", "filename", "followed", "by", "the", "tuple", "returned", "by", "calling", "os", ".", "stat", "on", "the", "filename", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L779-L792
234,099
dhylands/rshell
rshell/main.py
remove_file
def remove_file(filename, recursive=False, force=False): """Removes a file or directory.""" import os try: mode = os.stat(filename)[0] if mode & 0x4000 != 0: # directory if recursive: for file in os.listdir(filename): success = remove_file(filename + '/' + file, recursive, force) if not success and not force: return False os.rmdir(filename) # PGH Work like Unix: require recursive else: if not force: return False else: os.remove(filename) except: if not force: return False return True
python
def remove_file(filename, recursive=False, force=False): """Removes a file or directory.""" import os try: mode = os.stat(filename)[0] if mode & 0x4000 != 0: # directory if recursive: for file in os.listdir(filename): success = remove_file(filename + '/' + file, recursive, force) if not success and not force: return False os.rmdir(filename) # PGH Work like Unix: require recursive else: if not force: return False else: os.remove(filename) except: if not force: return False return True
[ "def", "remove_file", "(", "filename", ",", "recursive", "=", "False", ",", "force", "=", "False", ")", ":", "import", "os", "try", ":", "mode", "=", "os", ".", "stat", "(", "filename", ")", "[", "0", "]", "if", "mode", "&", "0x4000", "!=", "0", ":", "# directory", "if", "recursive", ":", "for", "file", "in", "os", ".", "listdir", "(", "filename", ")", ":", "success", "=", "remove_file", "(", "filename", "+", "'/'", "+", "file", ",", "recursive", ",", "force", ")", "if", "not", "success", "and", "not", "force", ":", "return", "False", "os", ".", "rmdir", "(", "filename", ")", "# PGH Work like Unix: require recursive", "else", ":", "if", "not", "force", ":", "return", "False", "else", ":", "os", ".", "remove", "(", "filename", ")", "except", ":", "if", "not", "force", ":", "return", "False", "return", "True" ]
Removes a file or directory.
[ "Removes", "a", "file", "or", "directory", "." ]
a92a8fa8074ac792241c83c640a51b394667c324
https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L810-L831