Uses head object to make sure the file exists in S3.
188493
def health_check(self):
        """"""
        logger.debug('Health Check on S3 file for: {namespace}'.format(
            namespace=self.namespace
        ))

        try:
            self.client.head_object(Bucket=self.bucket_name, Key=self.data_file)
            return True
        except ClientError as e:
            logger.debug('Error encountered with S3.  Assume unhealthy')
186930
def exists(self, filename):
        """"""
        client = boto3.client("s3")
        bucket, path = self.bucket_and_path(filename)
        r = client.list_objects(Bucket=bucket, Prefix=path, Delimiter="/")
        if r.get("Contents") or r.get("CommonPrefixes"):
            return True
        return False
62688
def _get_or_create_s3_bucket(s3, name):
    """"""
    exists = True
    try:
        s3.meta.client.head_bucket(Bucket=name)
    except botocore.exceptions.ClientError as e:
        error_code = int(e.response["Error"]["Code"])
        if error_code == 404:
            exists = False
        else:
            raise

    if not exists:
        s3.create_bucket(Bucket=name)

    return s3.Bucket(name)
272783
function fileExists(filename) {
    var d = Promise.defer();

    fs.exists(filename, function(exists) {
        d.resolve(exists);
    });

    return d.promise;
}
781313
def _bucket_exists(self):
        """"""
        try:
            self.s3client.get_bucket_location(Bucket=self.bucket)
            return True
        except ClientError as error:
            LOG.error(error)
            return False
570607
def _make_sure_dir_exists(self):
        
        filename = self.model_config.checkpoint_dir()
        pathlib.Path(filename).mkdir(parents=True, exist_ok=True)
744617
def bucket_exists(self, bucket_name):
        
        is_valid_bucket_name(bucket_name)

        try:
            self._url_open('HEAD', bucket_name=bucket_name)
        # If the bucket has not been created yet, MinIO will return a "NoSuchBucket" error.
        except NoSuchBucket:
            return False
        except ResponseError:
            raise
        return True
973920
function s3Init(file) {
  if (file.s3) {
    return;
  }

  file.s3 = {};
  file.s3.headers = {};
  file.s3.path = file.path.replace(file.base, "").replace(new RegExp("\\" + path.sep, "g"), "/");
}
102956
function fileExistsWithCaseSync (filepath) {
  const { base, dir, root } = path.parse(filepath)

  if (dir === root || dir === '.') {
    return true
  }

  try {
    const filenames = fs.readdirSync(dir)
    if (!filenames.includes(base)) {
      return false
    }
  } catch (e) {
    // dir does not exist
    return false
  }

  return fileExistsWithCaseSync(dir)
}
494613
def exists(self):
        
        return gf.file_exists(self.file_path) or gf.directory_exists(self.file_path)
3837
function existFile(filePath, mode = fs.constants.W_OK) {
  return new Promise((resolve, reject) => {
    fs.access(filePath, mode, (err) => {
      if (err) {
        reject(err);
        return;
      }
      resolve(filePath);
    });
  });
}
1356187
def check_dirs():
    
    dirs = [MAIN_DIR, TEMP_DIR, DOWNLOAD_DIR, SAVESTAT_DIR]
    for directory in dirs:
        if directory.exists() and not directory.is_dir():
            raise FileExistsError(str(directory.resolve()) + " cannot be used as a directory.")
1265987
def head(self, urls=None, **overrides):
        """"""
        if urls is not None:
            overrides['urls'] = urls
        return self.where(accept='HEAD', **overrides)
231343
function fileExist(fileName) {
  return new Promise((resolve, reject) => {
    fs.stat(fileName, (err, stats) => {
      if (err === null && stats.isFile()) {
        resolve(fileName);
      } else {
        resolve(false);
      }
    });
  });
}
136889
def head_bucket(self, name):
        
        try:
            self.s3.head_bucket(Bucket=name)
            info = self.s3.get_bucket_website(Bucket=self.sitename)
            if not info:
                return False, 404, "Configure improrperly"
            return True, None, None
        except botocore.exceptions.ClientError as e:
            if e.response["Error"]["Code"] in ["403", "404"]:
                return False, e.response["Error"]["Code"], e.response["Error"]["Message"]
            else:
                raise e
298314
def ensure_directory_exists(directory):
  '''
  '''
  if not os.path.exists(directory):
    os.makedirs(directory)
  elif os.path.isfile(directory):
    raise RuntimeError('Path %s is a file, not a directory.' % directory)
309602
function checkFile(peripheralId, callback) {
  if (overWriteServices) {
    callback(false);
  } else {
    fs.stat(devicesPath + '/' + peripheralId + '.srv.json', function(err, stat) {
      if(err == null) {
        callback(true);
        //  console.log('File exists');
      } else {
        callback(false)
      }
    });   
  }
}