#NEWLINE# def __call__( self , * args ) : #NEWLINE# #INDENT# self . __idcnt += 1 #NEWLINE# postdata = json . dumps ( { #NEWLINE# #INDENT# 'version' : '1.1' , #NEWLINE# 'method' : self . __serviceName , #NEWLINE# 'params' : args , #NEWLINE# 'id' : self . __idcnt , #NEWLINE# #UNINDENT# } ) #NEWLINE# try : #NEWLINE# #INDENT# self . __conn . request ( 'POST' , self . __url . path , postdata , { #NEWLINE# #INDENT# 'Host' : self . __url . hostname , #NEWLINE# 'User-Agent' : USER_AGENT , #NEWLINE# 'Authorization' : self . __authhdr , #NEWLINE# 'Content-type' : 'application/json' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# except EnvironmentError as e : #NEWLINE# #INDENT# if ( e . errno == errno . ECONNREFUSED ) : #NEWLINE# #INDENT# raise JSONRPCException ( { #NEWLINE# #INDENT# 'code' : ( - 341 ) , #NEWLINE# 'message' : 'connection refused' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# httpresp = self . __conn . getresponse ( ) #NEWLINE# if ( httpresp is None ) : #NEWLINE# #INDENT# raise JSONRPCException ( { #NEWLINE# #INDENT# 'code' : ( - 342 ) , #NEWLINE# 'message' : 'missing HTTP response from server' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# resp = json . loads ( httpresp . read ( ) , parse_float = decimal . Decimal ) #NEWLINE# if ( resp [ 'error' ] != None ) : #NEWLINE# #INDENT# raise JSONRPCException ( resp [ 'error' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'result' not in resp ) : #NEWLINE# #INDENT# raise JSONRPCException ( { #NEWLINE# #INDENT# 'code' : ( - 343 ) , #NEWLINE# 'message' : 'missing JSON-RPC result' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return resp [ 'result' ]