#NEWLINE# def set_key( self , key , value ) : #NEWLINE# #INDENT# url = ( '%(base)s/%(key)s' % { #NEWLINE# #INDENT# 'base' : self . url , #NEWLINE# 'key' : key , #NEWLINE# #UNINDENT# } ) #NEWLINE# data = ( 'value=%s' % value ) #NEWLINE# self . logger . debug ( ( 'Saving data: %(data)s to %(url)s' % { #NEWLINE# #INDENT# 'data' : data , #NEWLINE# 'url' : url , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# storage = StringIO ( ) #NEWLINE# curl = pycurl . Curl ( ) #NEWLINE# curl . setopt ( curl . URL , url ) #NEWLINE# curl . setopt ( curl . POSTFIELDS , data ) #NEWLINE# curl . setopt ( pycurl . FOLLOWLOCATION , 1 ) #NEWLINE# curl . setopt ( pycurl . MAXREDIRS , 5 ) #NEWLINE# curl . setopt ( curl . WRITEFUNCTION , storage . write ) #NEWLINE# curl . setopt ( pycurl . CUSTOMREQUEST , 'PUT' ) #NEWLINE# curl . perform ( ) #NEWLINE# response = curl . getinfo ( pycurl . HTTP_CODE ) #NEWLINE# curl . close ( ) #NEWLINE# if ( response == requests . codes . ok ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( response == requests . codes . created ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . logger . error ( ( 'ETCD returned %(status)s %(text)s' % { #NEWLINE# #INDENT# 'status' : response , #NEWLINE# 'text' : storage . getvalue ( ) , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# return None