<s> """<STR_LIT>""" <EOL> from __future__ import division , print_function , absolute_import <EOL> from . import util , constants <EOL> from . constants import * <EOL> completion_and_error_messages = { <EOL> VI_SUCCESS : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_SUCCESS_EVENT_EN : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_SUCCESS_EVENT_DIS : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_SUCCESS_QUEUE_EMPTY : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_SUCCESS_TERM_CHAR : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_SUCCESS_MAX_CNT : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_SUCCESS_DEV_NPRESENT : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_SUCCESS_TRIG_MAPPED : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_SUCCESS_QUEUE_NEMPTY : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_SUCCESS_NCHAIN : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_SUCCESS_NESTED_SHARED : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_SUCCESS_NESTED_EXCLUSIVE : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_SUCCESS_SYNC : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_WARN_QUEUE_OVERFLOW : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_WARN_CONFIG_NLOADED : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_WARN_NULL_OBJECT : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_WARN_NSUP_ATTR_STATE : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_WARN_UNKNOWN_STATUS : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_WARN_NSUP_BUF : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_WARN_EXT_FUNC_NIMPL : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_SYSTEM_ERROR : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_OBJECT : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_RSRC_LOCKED : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_EXPR : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_RSRC_NFOUND : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_RSRC_NAME : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_ACC_MODE : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_TMO : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_CLOSING_FAILED : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_DEGREE : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_JOB_ID : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NSUP_ATTR : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NSUP_ATTR_STATE : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_ATTR_READONLY : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_LOCK_TYPE : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_ACCESS_KEY : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_EVENT : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_MECH : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_HNDLR_NINSTALLED : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_HNDLR_REF : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_CONTEXT : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_QUEUE_OVERFLOW : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NENABLED : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_ABORT : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_RAW_WR_PROT_VIOL : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_RAW_RD_PROT_VIOL : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_OUTP_PROT_VIOL : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INP_PROT_VIOL : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_BERR : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_IN_PROGRESS : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_SETUP : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_QUEUE_ERROR : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_ALLOC : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_MASK : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_IO : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_FMT : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NSUP_FMT : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_LINE_IN_USE : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NSUP_MODE : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_SRQ_NOCCURRED : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_SPACE : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_OFFSET : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_WIDTH : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NSUP_OFFSET : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NSUP_VAR_WIDTH : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_WINDOW_NMAPPED : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_RESP_PENDING : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NLISTENERS : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NCIC : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NSYS_CNTLR : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NSUP_OPER : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INTR_PENDING : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_ASRL_PARITY : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_ASRL_FRAMING : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_ASRL_OVERRUN : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_TRIG_NMAPPED : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NSUP_ALIGN_OFFSET : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_USER_BUF : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_RSRC_BUSY : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NSUP_WIDTH : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_PARAMETER : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_PROT : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_SIZE : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_WINDOW_MAPPED : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NIMPL_OPER : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_LENGTH : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_MODE : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_SESN_NLOCKED : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_MEM_NSHARED : ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_LIBRARY_NFOUND : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NSUP_INTR : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INV_LINE : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_FILE_ACCESS : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_FILE_IO : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NSUP_LINE : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NSUP_MECH : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_INTF_NUM_NCONFIG : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_CONN_LOST : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_MACHINE_NAVAIL : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> VI_ERROR_NPERMISSION : ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> } <EOL> default_warnings = frozenset ( [ VI_SUCCESS_MAX_CNT , VI_SUCCESS_DEV_NPRESENT , <EOL> VI_SUCCESS_SYNC , VI_WARN_QUEUE_OVERFLOW , <EOL> VI_WARN_CONFIG_NLOADED , VI_WARN_NULL_OBJECT , <EOL> VI_WARN_NSUP_ATTR_STATE , VI_WARN_UNKNOWN_STATUS , <EOL> VI_WARN_NSUP_BUF , VI_WARN_EXT_FUNC_NIMPL ] ) <EOL> class Error ( Exception ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , description ) : <EOL> super ( Error , self ) . __init__ ( description ) <EOL> class VisaIOError ( Error ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , error_code ) : <EOL> abbreviation , description = completion_and_error_messages . get ( error_code , <EOL> ( '<STR_LIT:?>' , '<STR_LIT>' ) ) <EOL> super ( VisaIOError , self ) . __init__ ( '<STR_LIT>' % ( abbreviation , error_code , description ) ) <EOL> self . error_code = error_code <EOL> self . abbreviation = abbreviation <EOL> self . description = description <EOL> class VisaIOWarning ( Warning ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , error_code ) : <EOL> abbreviation , description = completion_and_error_messages . get ( error_code , <EOL> ( '<STR_LIT:?>' , '<STR_LIT>' ) ) <EOL> super ( VisaIOWarning , self ) . __init__ ( '<STR_LIT>' % ( abbreviation , error_code , description ) ) <EOL> self . error_code = error_code <EOL> self . abbreviation = abbreviation <EOL> self . description = description <EOL> class VisaTypeError ( Error ) : <EOL> """<STR_LIT>""" <EOL> class UnknownHandler ( Error ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , event_type , handler , user_handle ) : <EOL> super ( UnknownHandler , self ) . __init__ ( '<STR_LIT>' % ( event_type , handler , user_handle ) ) <EOL> class OSNotSupported ( Error ) : <EOL> def __init__ ( self , os ) : <EOL> super ( OSNotSupported , self ) . __init__ ( os + "<STR_LIT>" ) <EOL> class InvalidBinaryFormat ( Error ) : <EOL> def __init__ ( self , description = "<STR_LIT>" ) : <EOL> if description : <EOL> description = "<STR_LIT>" + description <EOL> super ( InvalidBinaryFormat , self ) . __init__ ( "<STR_LIT>" + description ) <EOL> class InvalidSession ( Error ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( InvalidSession , self ) . __init__ ( '<STR_LIT>' ) <EOL> class LibraryError ( OSError , Error ) : <EOL> @ classmethod <EOL> def from_exception ( cls , exc , filename ) : <EOL> try : <EOL> msg = str ( exc ) <EOL> if '<STR_LIT>' in msg : <EOL> msg = '<STR_LIT>' <EOL> elif '<STR_LIT>' in msg : <EOL> if '<STR_LIT>' in msg : <EOL> return LibraryError . from_wrong_arch ( filename ) <EOL> else : <EOL> msg = '<STR_LIT>' <EOL> elif '<STR_LIT>' in msg : <EOL> return LibraryError . from_wrong_arch ( filename ) <EOL> except UnicodeDecodeError : <EOL> return cls ( '<STR_LIT>' % filename ) <EOL> return cls ( '<STR_LIT>' % ( filename , msg ) ) <EOL> @ classmethod <EOL> def from_wrong_arch ( cls , filename ) : <EOL> s = '<STR_LIT>' <EOL> details = util . get_system_details ( backends = False ) <EOL> visalib = util . LibraryPath ( filename , '<STR_LIT:user>' if filename == util . read_user_library_path ( ) else '<STR_LIT>' ) <EOL> s += '<STR_LIT>' <EOL> s += '<STR_LIT>' % details [ '<STR_LIT>' ] <EOL> s += '<STR_LIT>' % visalib . path <EOL> s += '<STR_LIT>' % visalib . found_by <EOL> s += '<STR_LIT>' % visalib . bitness <EOL> return cls ( '<STR_LIT>' % ( filename , s ) ) <EOL> def _args_to_str ( args , kwargs ) : <EOL> return '<STR_LIT>' % ( args , kwargs ) <EOL> def return_handler ( module_logger , first_is_session = True ) : <EOL> """<STR_LIT>""" <EOL> def _outer ( visa_library_method ) : <EOL> def _inner ( self , session , * args , ** kwargs ) : <EOL> ret_value = visa_library_method ( * args , ** kwargs ) <EOL> module_logger . debug ( '<STR_LIT>' , <EOL> visa_library_method . __name__ , <EOL> _args_to_str ( args , kwargs ) , <EOL> ret_value ) <EOL> try : <EOL> ret_value = constants . StatusCode ( ret_value ) <EOL> except ValueError : <EOL> pass <EOL> if first_is_session : <EOL> self . _last_status = ret_value <EOL> self . _last_status_in_session [ session ] = ret_value <EOL> if ret_value < <NUM_LIT:0> : <EOL> raise VisaIOError ( ret_value ) <EOL> if ret_value in self . issue_warning_on : <EOL> if session and ret_value not in self . _ignore_warning_in_session [ session ] : <EOL> module_logger . warn ( VisaIOWarning ( ret_value ) , stacklevel = <NUM_LIT:2> ) <EOL> return ret_value <EOL> return _inner <EOL> return _outer </s>
