#NEWLINE# def set_label( self , item , label , changed ) : #NEWLINE# #INDENT# if ( not changed ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# bundle = { #NEWLINE# #INDENT# 'label' : { #NEWLINE# #INDENT# 'external_id' : self . encode ( item ) , #NEWLINE# 'text' : self . encode ( label ) , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# params = json . dumps ( bundle ) #NEWLINE# connection = httplib . HTTPConnection ( self . target_host ) #NEWLINE# connection . request ( 'POST' , ( '/api/wallets/%s/labels.json?auth_token=%s' % ( self . wallet_id , self . auth_token ( ) ) ) , params , { #NEWLINE# #INDENT# 'Content-Type' : 'application/json' , #NEWLINE# #UNINDENT# } ) #NEWLINE# response = connection . getresponse ( ) #NEWLINE# if ( response . reason == httplib . responses [ httplib . NOT_FOUND ] ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# response = json . loads ( response . read ( ) ) #NEWLINE# #UNINDENT# except socket . gaierror as e : #NEWLINE# #INDENT# print_error ( ( 'Error connecting to service: %s ' % e ) ) #NEWLINE# return False