RAID alert messages.

        [available/used] means that ideally the array may have _available_
        devices however, _used_ devices are in use.
        Obviously when used >= available then things are good.
548928
def raid_alert(self, status, used, available, type):
        
        if type == 'raid0':
            return 'OK'
        if status == 'inactive':
            return 'CRITICAL'
        if used is None or available is None:
            return 'DEFAULT'
        elif used < available:
            return 'WARNING'
        return 'OK'
928023
def first_available(self, *quantities):
        
        for i, q in enumerate(quantities):
            if self.has_quantity(q):
                if i:
                    warnings.warn('{} not available; using {} instead'.format(quantities[0], q))
                return q
1266358
def _get(self, *args, **kwargs):
        
        all_messages = []
        for storage in self.storages:
            messages, all_retrieved = storage._get()
            # If the backend hasn't been used, no more retrieval is necessary.
            if messages is None:
                break
            if messages:
                self._used_storages.add(storage)
            all_messages.extend(messages)
            # If this storage class contained all the messages, no further
            # retrieval is necessary
            if all_retrieved:
                break
        return all_messages, all_retrieved
250693
def available_events
      state = current_state
      ret = {}
      while(state) do
        ret = state.class.specification.events.merge(ret)
        state = state.parent_state
      end
      ret
    end
542036
def get_available_positions(self):
        
        available_positions = ["new"]
        layout = self.context.getLayout()
        used_positions = [int(slot["position"]) for slot in layout]
        if used_positions:
            used = [
                pos for pos in range(1, max(used_positions) + 1) if
                pos not in used_positions]
            available_positions.extend(used)
        return available_positions
991641
def _get_existing_logical_drives(raid_adapter):
    
    existing_logical_drives = []
    logical_drives = raid_adapter['Server']['HWConfigurationIrmc'][
        'Adapters']['RAIDAdapter'][0].get('LogicalDrives')
    if logical_drives is not None:
        for drive in logical_drives['LogicalDrive']:
            existing_logical_drives.append(drive['@Number'])

    return existing_logical_drives
1243739
static String[] getUsable(final List<String> available, final String[] supported)
    {
        final List<String> filtered = new ArrayList<String>(available.size());
        final List<String> supportedList = Arrays.asList(supported);

        for (final String s : available)
        {
            if (supportedList.contains(s)) filtered.add(s);
        }

        final String[] filteredArray = new String[filtered.size()];
        filtered.toArray(filteredArray);
        return filteredArray;
    }
890380
def available?(an_rpc)
      return an_rpc if @pool.ready_for_work?
      GRPC.logger.warn('no free worker threads currently')
      noop = proc { |x| x }

      # Create a new active call that knows that metadata hasn't been
      # sent yet
      c = ActiveCall.new(an_rpc.call, noop, noop, an_rpc.deadline,
                         metadata_received: true, started: false)
      c.send_status(GRPC::Core::StatusCodes::RESOURCE_EXHAUSTED,
                    'No free threads in thread pool')
      nil
    end
48113
def read_used():
    
    used_hashes = {"evs": set([]),
                   "cache": set([]),
                   "seeds": set([])}

    with open(LOG_FILEPATH, 'rb') as logfile:
        for line in logfile.readlines():
            kind, hash = tuple(line.split('...'))
            used_hashes[kind].add(hash.rstrip())

    return used_hashes
444707
@Override
    public int available() throws IOException {
        abortIfNeeded();
        int available = this.decryptedContents.available();
        if(available < this.virtualAvailable) {
            return available;
        } else {
            // Limit the number of bytes available to the number
            // of bytes remaining in the range.
            return (int)this.virtualAvailable;
        }
    }
293557
def accessed(name, value)
      @accessed ||= {}
      @accessed[name] = value.dup if (value.is_a?(Array) || value.is_a?(Hash)) && !@accessed.has_key?(name)
      value
    end
894054
def used_in_func(statement: str, filename: str = '<string>',
                 mode: str = 'exec'):
    ''''''
    try:
        return get_used_in_func(ast.parse(statement, filename, mode))
    except Exception as e:
        raise RuntimeError(f'Failed to parse statement: {statement} {e}')
1073832
function needRecurseArray(arr) {
  for (var i = 0; i < arr.length; i++) {
    var el = arr[i]
    if (typeof el !== 'number' && typeof el !== 'string' && el != null) return true
  }
  return false
}
1980
public static boolean shouldRaid(Configuration conf, FileSystem srcFs, 
      FileStatus stat, Codec codec, List<FileStatus> lfs) throws IOException {
    Path p = stat.getPath();
    long blockNum = 0L;
    if (stat.isDir() != codec.isDirRaid) {
      return false;
    }
    
    if (tooNewForRaid(stat)) {
      return false;
    }
    
    blockNum = codec.isDirRaid ? 
        DirectoryStripeReader.getBlockNum(lfs) : numBlocks(stat);
    
    // if the file/directory has fewer than 2 blocks, then nothing to do
    if (blockNum <= RaidState.TOO_SMALL_NOT_RAID_NUM_BLOCKS) {
      return false;
    }
    
    return !raidedByOtherHighPriCodec(conf, stat, codec);
  }
628279
def is_available(self):
        
        # if the availability flag is raised, return True immediately.
        # NOTE: subsequent API failures will lower this flag. we do this here
        # to ensure we don't keep hitting Cuckoo with requests while
        # availability is there.
        if self.server_available:
            return True

        # otherwise, we have to check with the cloud.
        else:
            try:
                response = self._request("cuckoo/status")

                # we've got cuckoo.
                if response.status_code == 200:
                    self.server_available = True
                    return True

            except sandboxapi.SandboxError:
                pass

        self.server_available = False
        return False
1255330
def _events_available_during_other_events(
    events, slots, X, summation_type=None, **kwargs
):
    
    summation = lpu.summation_functions[summation_type]
    event_availability_array = lpu.event_availability_array(events)

    label = 'Event clashes with another event'
    for slot1, slot2 in lpu.concurrent_slots(slots):
        for row, event in enumerate(event_availability_array):
            if events[row].unavailability:
                for col, availability in enumerate(event):
                    if availability == 0:
                        yield Constraint(
                            f'{label} - event: {row} and event: {col}',
                            summation(
                                (X[row, slot1], X[col, slot2])
                            ) <= 1 + availability
                        )
525740
@Override
	public int available() {
		// In Secure DFU softdevice and bootloader sizes are not provided in the Init file
        // (they are encoded inside the Init file instead). The service doesn't send those sizes,
        // not the whole size of the firmware separately, like it was done in the Legacy DFU.
		// This method then is just used to log file size.

		// In case of SD+BL in Secure DFU:
		if (softDeviceAndBootloaderBytes != null && softDeviceSize == 0 && bootloaderSize == 0
				&& (type & (DfuBaseService.TYPE_SOFT_DEVICE | DfuBaseService.TYPE_BOOTLOADER)) > 0)
			return softDeviceAndBootloaderBytes.length + applicationImageSize() - bytesRead;

		// Otherwise:
		return softDeviceImageSize() + bootloaderImageSize() + applicationImageSize() - bytesRead;
	}