#NEWLINE# def __init__( self , device , debug = False , timeout = 1 , test_comm = True ) : #NEWLINE# #INDENT# self . debug = debug #NEWLINE# if device . startswith ( 'yhsm://' ) : #NEWLINE# #INDENT# self . stick = pyhsm . stick_client . YHSM_Stick_Client ( device ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . stick = pyhsm . stick . YHSM_Stick ( device , debug = self . debug , timeout = timeout ) #NEWLINE# #UNINDENT# if ( not self . reset ( test_sync = False ) ) : #NEWLINE# #INDENT# raise pyhsm . exception . YHSM_Error ( 'Initialization of YubiHSM failed' ) #NEWLINE# #UNINDENT# self . version = pyhsm . version . YHSM_Version ( self . info ( ) ) #NEWLINE# if ( self . version . sysinfo . protocol_ver != pyhsm . defines . YSM_PROTOCOL_VERSION ) : #NEWLINE# #INDENT# raise pyhsm . exception . YHSM_Error ( ( 'Unknown YubiHSM protocol version (%i, I speak %i)' % ( debug . version . sysinfo . protocol_ver , pyhsm . defines . YSM_PROTOCOL_VERSION ) ) ) #NEWLINE# #UNINDENT# if test_comm : #NEWLINE# #INDENT# self . test_comm ( ) #NEWLINE# #UNINDENT# return None