Verify sufficient space is available on destination file system (return boolean).
356449
def verify_space_available(self, search_pattern=r"(\d+) \w+ free"):
        """"""
        if self.direction == "put":
            space_avail = self.remote_space_available(search_pattern=search_pattern)
        elif self.direction == "get":
            space_avail = self.local_space_available()
        if space_avail > self.file_size:
            return True
        return False
597167
def _verify_file_size(self):
        
        if self._file_size > PartSize.MAXIMUM_OBJECT_SIZE:
            self._status = TransferState.FAILED
            raise SbgError('File size = {}b. Maximum file size is {}b'.format(
                self._file_size, PartSize.MAXIMUM_OBJECT_SIZE)
            )
314081
def disk_usage(path, human=False):
    """"""
    command = ['du', '-s', path]
    if human:
        command.append('-h')

    return subprocess.check_output(command).split()[0].decode('utf-8')
1245565
def _validate_completeness(self):
        
        errors = list()

        # First we'll make sure there's no mismatch between the filesystem
        # and the list of files in the manifest(s)
        only_in_manifests, only_on_fs, only_in_fetch = self.compare_manifests_with_fs_and_fetch()
        for path in only_in_manifests:
            e = FileMissing(path)
            LOGGER.warning(force_unicode(e))
            errors.append(e)
        for path in only_on_fs:
            e = UnexpectedFile(path)
            LOGGER.warning(force_unicode(e))
            errors.append(e)
        for path in only_in_fetch:
            e = UnexpectedRemoteFile(path)
            # this is non-fatal according to spec but the warning is still reasonable
            LOGGER.warning(force_unicode(e))

        if errors:
            raise BagValidationError(_("Bag validation failed"), errors)
409534
private boolean hasEnoughDiskSpace(ClusterNode node) {
    int total = node.getTotal().diskGB;
    int free = node.getFree().diskGB;
    if (free < nodeReservedDiskGB) {
      if (LOG.isDebugEnabled()) {
        LOG.debug(node.getHost() + " not enough disk space." +
          " totalMB:" + total +
          " free:" + free +
          " limit:" + nodeReservedDiskGB);
      }
      return false;
    }
    return true;
  }
1094155
private void checkSize(long newSize, long maxSize, HttpServerFileUpload upload) {
        if (maxSize >= 0 && newSize > maxSize) {
            upload.handler(null);
            report(new IllegalStateException("Size exceed allowed maximum capacity"));
        }
    }
882049
def getFileSystemSize(dirPath):
    
    assert os.path.exists(dirPath)
    diskStats = os.statvfs(dirPath)
    freeSpace = diskStats.f_frsize * diskStats.f_bavail
    diskSize = diskStats.f_frsize * diskStats.f_blocks
    return freeSpace, diskSize
203444
def get_reserved_space(self):
        """"""
        reserved_space_ratio = .45
        max_reserved_space = 8
        _, height = click.get_terminal_size()
        return min(int(round(height * reserved_space_ratio)), max_reserved_space)
1140427
def _check(self): # TODO: fix?
        """"""
        if self._returncode:
            rarfile.check_returncode(self, '')
        if self._remain != 0:
            raise rarfile.BadRarFile("Failed the read enough data")
677945
def validate_capacity(capacity):
    """"""

    if capacity not in VALID_SCALING_CONFIGURATION_CAPACITIES:
        raise ValueError(
            "ScalingConfiguration capacity must be one of: {}".format(
                ", ".join(map(
                    str,
                    VALID_SCALING_CONFIGURATION_CAPACITIES
                ))
            )
        )
    return capacity
316084
def capacity(self):
        
        _complain_ifclosed(self.closed)
        if not self.__status.host:
            raise RuntimeError('Capacity is not defined for a local fs')
        return self.fs.get_capacity()
1044996
def _check_limit(self):
        """"""

        # First compress
        self._compress()

        # Then check the max size
        if len(self._store) >= self._max_size:
            self._store.popitem(last=False)
122575
def _ensure_file_is_good(self, current_time):
        """"""
        if self._last_file_mapping_update and current_time - self._last_file_mapping_update <= self._stat_interval:
            return

        self._last_file_mapping_update = time.time()

        try:
            st = os.stat(self._filename)
        except EnvironmentError, err:
            if err.errno == errno.ENOENT:
                self._log_info('file removed')
                self.close()
                return
            raise

        fid = self.get_file_id(st)
        if fid != self._fid:
            self._log_info('file rotated')
            self.close()
        elif self._file.tell() > st.st_size:
            if st.st_size == 0 and self._ignore_truncate:
                self._logger.info("[{0}] - file size is 0 {1}. ".format(fid, self._filename) +
                                  "If you use another tool (i.e. logrotate) to truncate " +
                                  "the file, your application may continue to write to " +
                                  "the offset it last wrote later. In such a case, we'd " +
                                  "better do nothing here")
                return
            self._log_info('file truncated')
            self._update_file(seek_to_end=False)
        elif REOPEN_FILES:
            self._log_debug('file reloaded (non-linux)')
            position = self._file.tell()
            self._update_file(seek_to_end=False)
            if self.active:
                self._file.seek(position, os.SEEK_SET)
1334398
def size(self):
        ''''''
        try:
            return os.fstat(self.file.fileno()).st_size
        except io.UnsupportedOperation:
            pass

        if is_seekable(self.file):
            with wpull.util.reset_file_offset(self.file):
                self.file.seek(0, os.SEEK_END)
                return self.file.tell()

        raise OSError('Unsupported operation.')
842041
def isemptyfile(filepath):
    
    exists = os.path.exists(safepath(filepath))
    if exists:
        filesize = os.path.getsize(safepath(filepath))
        return filesize == 0
    else:
        return False
1039762
private void checkUserFileBufferBytes() {
    if (!isSet(PropertyKey.USER_FILE_BUFFER_BYTES)) { // load from hadoop conf
      return;
    }
    long usrFileBufferBytes = getBytes(PropertyKey.USER_FILE_BUFFER_BYTES);
    Preconditions.checkState((usrFileBufferBytes & Integer.MAX_VALUE) == usrFileBufferBytes,
        PreconditionMessage.INVALID_USER_FILE_BUFFER_BYTES.toString(),
        PropertyKey.Name.USER_FILE_BUFFER_BYTES, usrFileBufferBytes);
  }
1256495
def check_file_size(file_size, path):
        
        stat_info = os.stat(path)
        if stat_info.st_size != file_size:
            format_str = "Error occurred downloading {}. Got a file size {}. Expected file size:{}"
            msg = format_str.format(path, stat_info.st_size, file_size)
            raise ValueError(msg)