#NEWLINE# def write( self , key , value , ttl = None , directory = False ) : #NEWLINE# #INDENT# if directory : #NEWLINE# #INDENT# value = None #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# result = self . client . write ( key , value , ttl = ttl , dir = directory ) #NEWLINE# #UNINDENT# except ( etcd . EtcdNotFile , etcd . EtcdNotDir , etcd . EtcdRootReadOnly , ValueError ) as err : #NEWLINE# #INDENT# log . error ( 'etcd: {0}' . format ( err ) ) #NEWLINE# return None #NEWLINE# #UNINDENT# except MaxRetryError as err : #NEWLINE# #INDENT# log . error ( 'etcd: Could not connect to etcd server: {0}' . format ( err ) ) #NEWLINE# return None #NEWLINE# #UNINDENT# except Exception as err : #NEWLINE# #INDENT# log . error ( 'etcd: uncaught exception {0}' . format ( err ) ) #NEWLINE# raise #NEWLINE# #UNINDENT# if directory : #NEWLINE# #INDENT# return getattr ( result , 'dir' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return getattr ( result , 'value' )