Ensures that the pgrp file is present and up to date. There have
        been production cases where the file was lost or not
        immediately emitted due to disk space issues.
765768
def _ensure_pgrp(self):
        
        if not LAST_PGRP_PATH:  # global
            return
        try:
            with open(LAST_PGRP_PATH, 'w') as f:
                f.write(str(os.getpgrp()) + "\n")
        except IOError:
            # raised if no permissions or disk space
            pass
758321
private void ensureFoldersExist() {

        for (String path : Arrays.asList(IMPORT_FOLDER_PATH, EXPORT_FOLDER_PATH)) {
            String folderPath = OpenCms.getSystemInfo().getAbsoluteRfsPathRelativeToWebInf(path);
            File folder = new File(folderPath);
            if (!folder.exists()) {
                folder.mkdirs();
            }
        }
    }
391519
def ensure_path_exists(self):
        # type: (LocalDestinationPath) -> None
        
        if self._is_dir is None:
            raise RuntimeError('is_dir not set')
        if self._is_dir:
            self._path.mkdir(mode=0o750, parents=True, exist_ok=True)
        else:
            if self._path.exists() and self._path.is_dir():
                raise RuntimeError(
                    ('destination path {} already exists and is a '
                     'directory').format(self._path))
            else:
                # ensure parent path exists and is created
                self._path.parent.mkdir(
                    mode=0o750, parents=True, exist_ok=True)
41588
def is_valid_file(parser, arg):
    """"""
    arg = os.path.abspath(arg)
    if not os.path.exists(arg):
        parser.error("The file %s does not exist!" % arg)
    else:
        return arg
1250183
def ensure_resource_data(self, update_data=False):
        
        # Check for unique identifier in the resource data
        if not any(key in self.data for key in self.UNIQUE_IDENTIFIERS):
            raise exceptions.HPOneViewMissingUniqueIdentifiers(MISSING_UNIQUE_IDENTIFIERS)

        # Returns if data update is not required
        if not update_data:
            return

        resource_data = None

        if 'uri' in self.UNIQUE_IDENTIFIERS and self.data.get('uri'):
            resource_data = self._helper.do_get(self.data['uri'])
        else:
            for identifier in self.UNIQUE_IDENTIFIERS:
                identifier_value = self.data.get(identifier)

                if identifier_value:
                    result = self.get_by(identifier, identifier_value)
                    if result and isinstance(result, list):
                        resource_data = result[0]
                        break

        if resource_data:
            self.data.update(resource_data)
        else:
            raise exceptions.HPOneViewResourceNotFound(RESOURCE_DOES_NOT_EXIST)
447744
def update(self, source_file, configuration, declarations, included_files):
        

        record = record_t(
            source_signature=file_signature(source_file),
            config_signature=configuration_signature(configuration),
            included_files=included_files,
            included_files_signature=list(
                map(
                    file_signature,
                    included_files)),
            declarations=declarations)
        # Switched over to holding full record in cache so we don't have
        # to keep creating records in the next method.
        self.__cache[record.key()] = record
        self.__cache[record.key()].was_hit = True
        self.__needs_flushed = True
903405
public boolean needPersistence(long fileId) {
    if (isFilePersisting(fileId) || isFilePersisted(fileId)) {
      return false;
    }

    try {
      String ufsFingerprint = ufsFingerprint(fileId);
      if (ufsFingerprint != null) {
        // mark as persisted
        addPersistedFile(fileId, ufsFingerprint);
        return false;
      }
    } catch (Exception e) {
      LOG.warn("Failed to check if file {} exists in under storage system: {}",
               fileId, e.getMessage());
      LOG.debug("Exception: ", e);
    }
    return true;
  }
87503
def ensure_file(path):
        
        try:
            exists = isfile(path)
            if not exists:
                with open(path, 'w+') as fname:
                    fname.write('initialized')
                return (True, path)
            return (True, 'exists')
        except OSError as e:  # pragma: no cover
            return (False, e)
1098283
def file_uptodate(fname, cmp_fname):
    
    try:
        return (file_exists(fname) and file_exists(cmp_fname) and
                os.path.getmtime(fname) >= os.path.getmtime(cmp_fname))
    except OSError:
        return False
665798
def files_exist(self):
        
        if not os.path.isfile(self.path + self.script):
            print("\nslpkg: Error: SlackBuild archive.tar.gz not found\n")
            raise SystemExit()
        for src in self.sources:
            if not os.path.isfile(self.path + src):
                print("\nslpkg: Error: Source file '{0}' not found\n".format(
                    src))
                raise SystemExit()
1115155
private function ensureFileIndexes()
    {
        $indexKey = ['filename' => 1, 'uploadDate' => 1];
        foreach ($this->listIndexes() as $index) {
            if ($index['key'] === $indexKey) {
                return;
            }
        }

        $this->createIndex($indexKey);
    }
1046015
def ensure_lockfile(keep_outdated=False, pypi_mirror=None):
    """"""
    if not keep_outdated:
        keep_outdated = project.settings.get("keep_outdated")
    # Write out the lockfile if it doesn't exist, but not if the Pipfile is being ignored
    if project.lockfile_exists:
        old_hash = project.get_lockfile_hash()
        new_hash = project.calculate_pipfile_hash()
        if new_hash != old_hash:
            click.echo(
                crayons.red(
                    fix_utf8("Pipfile.lock ({0}) out of date, updating to ({1})…".format(
                        old_hash[-6:], new_hash[-6:]
                    )),
                    bold=True,
                ),
                err=True,
            )
            do_lock(keep_outdated=keep_outdated, pypi_mirror=pypi_mirror)
    else:
        do_lock(keep_outdated=keep_outdated, pypi_mirror=pypi_mirror)
1023028
def is_valid_pid_to_be_updated(did):
    """"""
    return (
        is_existing_object(did)
        and not is_local_replica(did)
        and not is_archived(did)
        and not is_obsoleted(did)
    )
1181405
def verify(self):
        

        # remember file pointer
        pos = self.tell()
        self.seek(0)

        checksum = 0
        for chunk in iter(lambda: self.read(1024), b''):
            checksum = crc32(chunk, checksum)

        # restore file pointer
        self.seek(pos)

        return self.crc32 == checksum & 0xffffffff
369487
def _is_current(self, file_path, zip_path):
        
        timestamp, size = self._get_date_and_size(self.zipinfo[zip_path])
        if not os.path.isfile(file_path):
            return False
        stat = os.stat(file_path)
        if stat.st_size != size or stat.st_mtime != timestamp:
            return False
        # check that the contents match
        zip_contents = self.loader.get_data(zip_path)
        with open(file_path, 'rb') as f:
            file_contents = f.read()
        return zip_contents == file_contents
844897
function ensureDir(filename) {
    var fs = require('fs');
    var path = require('path');
    var dir = path.dirname(filename);
    if (!fs.existsSync(dir)) {
        var mkdirp = require('mkdirp').sync;
        mkdirp(dir);
    }
}
258733
def update_file_status(self):
        """"""
        nfiles = len(self.cache.keys())
        status_vect = np.zeros((6), int)
        sys.stdout.write("Updating status of %i files: " % nfiles)
        sys.stdout.flush()
        for i, key in enumerate(self.cache.keys()):
            if i % 200 == 0:
                sys.stdout.write('.')
                sys.stdout.flush()
            fhandle = self.cache[key]
            fhandle.check_status(self._base_path)
            fhandle.update_table_row(self._table, fhandle.key - 1)
            status_vect[fhandle.status] += 1

        sys.stdout.write("!\n")
        sys.stdout.flush()
        sys.stdout.write("Summary:\n")
        sys.stdout.write("  no_file:      %i\n" % status_vect[0])
        sys.stdout.write("  expected:     %i\n" % status_vect[1])
        sys.stdout.write("  exists:       %i\n" % status_vect[2])
        sys.stdout.write("  missing:      %i\n" % status_vect[3])
        sys.stdout.write("  superseded:   %i\n" % status_vect[4])
        sys.stdout.write("  temp_removed: %i\n" % status_vect[5])