def write(self, key, value, ttl=None, directory=False):
        # directories can't have values, but have to have it passed
        if directory:
            value = None
        try:
            result = self.client.write(key, value, ttl=ttl, dir=directory)
        except (etcd.EtcdNotFile, etcd.EtcdNotDir, etcd.EtcdRootReadOnly, __HOLE__) as err:
            log.error('etcd: {0}'.format(err))
            return None
        except MaxRetryError as err:
            log.error("etcd: Could not connect to etcd server: {0}".format(err))
            return None
        except Exception as err:
            log.error('etcd: uncaught exception {0}'.format(err))
            raise

        if directory:
            return getattr(result, 'dir')
        else:
            return getattr(result, 'value')
dataset/ETHPy150Open saltstack/salt/salt/utils/etcd_util.py/EtcdClient.write