Get slot information from qstat
352076
def _sge_get_slots(xmlstring):
    
    rootxml = ET.fromstring(xmlstring)
    my_machine_dict = {}
    for queue_list in rootxml.iter("Queue-List"):
        # find all hosts supporting queues
        my_hostname = queue_list.find("name").text.rsplit("@")[-1]
        my_slots = queue_list.find("slots_total").text
        my_machine_dict[my_hostname] = {}
        my_machine_dict[my_hostname]["slots_total"] = int(my_slots)
    return my_machine_dict
476215
def display_stats(self):
        """"""
        for i, one_stage in enumerate(STAGE_NAME):
            second_in_stage = self.annot.time_in_stage(one_stage)
            time_in_stage = str(timedelta(seconds=second_in_stage))

            label = self.idx_stage_stats.itemAt(i,
                                                QFormLayout.FieldRole).widget()
            label.setText(time_in_stage)

        for i, one_qual in enumerate(QUALIFIERS):
            second_in_qual = self.annot.time_in_stage(one_qual, attr='quality')
            time_in_qual = str(timedelta(seconds=second_in_qual))

            label = self.idx_qual_stats.itemAt(i,
                                               QFormLayout.FieldRole).widget()
            label.setText(time_in_qual)
721405
def slot_status(slot_id, expected_replenishment_date, remaining_quantity_in_unit, original_quantity_in_unit, total_quantity_on_hand, last_use_date)
      headers = {
        'x-amzn-accept-type': 'com.amazon.dash.replenishment.DrsSlotStatusResult@1.0',
        'x-amzn-type-version': 'com.amazon.dash.replenishment.DrsSlotStatusInput@1.0'
      }
      path = "/slotStatus/#{slot_id}"
      params = {
        'expectedReplenishmentDate' => convert_to_iso8601(expected_replenishment_date),
        'remainingQuantityInUnit' => remaining_quantity_in_unit,
        'originalQuantityInUnit' => original_quantity_in_unit,
        'totalQuantityOnHand' => total_quantity_on_hand,
        'lastUseDate' => convert_to_iso8601(last_use_date)
      }
      response = request_drs(:post, path, headers: headers, params: params)
      if response.code == '200'
        ::AmazonDrs::SlotStatus.new(response)
      else
        ::AmazonDrs::Error.new(response)
      end
    end
886112
def _get_externalcmd_stats(self, app_stats):
        
        khigh = "high_external_command_buffer_slots"
        ktotal = "total_external_command_buffer_slots"
        kused = "used_external_command_buffer_slots"
        kstats = "external_command_stats"
        aliases = {
            khigh: "external_command.buffer_high",
            ktotal: "external_command.buffer_total",
            kused: "external_command.buffer_used",
            "x01": "external_command.01",
            "x05": "external_command.05",
            "x15": "external_command.15",
        }
        stats = {}
        if khigh in app_stats.keys() and str(app_stats[khigh]).isdigit():
            key = aliases[khigh]
            stats[key] = int(app_stats[khigh])

        if ktotal in app_stats.keys() and str(app_stats[ktotal].isdigit()):
            key = aliases[ktotal]
            stats[key] = int(app_stats[ktotal])

        if kused in app_stats.keys() and str(app_stats[kused].isdigit()):
            key = aliases[kused]
            stats[key] = int(app_stats[ktotal])

        if kstats in app_stats.keys():
            (x01, x05, x15) = self._convert_tripplet(app_stats[kstats])
            stats[aliases["x01"]] = x01
            stats[aliases["x05"]] = x05
            stats[aliases["x01"]] = x15

        return stats
403619
def retrieve_pool_stats(self, pool, **_params):
        """"""
        return self.get(self.pool_path_stats % (pool), params=_params)
979735
def slot_obj_dict(o):
    
    d = {}
    for f in o.__slots__:
        d[f] = getattr(o, f, None)
    return d
239288
private function get_slot() {
		for ($i = 0; $i < $this->max_processes; $i++) {
			if ($this->processes[$i] == -1) {
				return $i;
			}
		}
		return -1;
	}
110340
def toRepr (obj):
    
    args  = [ ]
    names = [ ]

    if hasattr(obj, "__dict__"):
        names += getattr(obj, "__dict__").keys()
    if hasattr(obj, "__slots__"):
        names += getattr(obj, "__slots__")

    for name in names:
        value = getattr(obj, name)
        if value is not None:
            if type(value) is str:
                if len(value) > 32:
                    value = value[0:32] + "..."
                value = "'" + value + "'"
        args.append("%s=%s" % (name, str(value)))

    return "%s(%s)" % (obj.__class__.__name__, ", ".join(args))
254637
def _determine_slot(self, *args):
        
        if len(args) <= 1:
            raise RedisClusterException("No way to dispatch this command to Redis Cluster. Missing key.")
        command = args[0]

        if command in ['EVAL', 'EVALSHA']:
            numkeys = args[2]
            keys = args[3: 3 + numkeys]
            slots = {self.connection_pool.nodes.keyslot(key) for key in keys}
            if len(slots) != 1:
                raise RedisClusterException("{0} - all keys must map to the same key slot".format(command))
            return slots.pop()

        key = args[1]

        return self.connection_pool.nodes.keyslot(key)
35431
def _get_total_available_slots(self, context, template_id, capacity):
        
        query = context.session.query(hd_models.HostingDevice.id)
        query = query.outerjoin(
            hd_models.SlotAllocation,
            hd_models.HostingDevice.id == hd_models.SlotAllocation
            .hosting_device_id)
        query = query.filter(
            hd_models.HostingDevice.template_id == template_id,
            hd_models.HostingDevice.admin_state_up == expr.true(),
            hd_models.HostingDevice.tenant_bound == expr.null())
        query = query.group_by(hd_models.HostingDevice.id)
        query = query.having(
            func.sum(hd_models.SlotAllocation.num_allocated) == expr.null())
        num_hosting_devices = query.count()
        return num_hosting_devices * capacity
195442
def print_signals_and_slots(self):
        
        for i in xrange(self.metaObject().methodCount()):
             m = self.metaObject().method(i)
             if m.methodType() == QMetaMethod.MethodType.Signal:
                 print("SIGNAL: sig=", m.signature(), "hooked to nslots=", self.receivers(SIGNAL(m.signature())))
             elif m.methodType() == QMetaMethod.MethodType.Slot:
                 print("SLOT: sig=", m.signature())
681208
def get_slot_bindings(self):
        

        slot_bindings = yield from self._hypervisor.send('vm slot_bindings "{}"'.format(self._name))
        return slot_bindings
268117
def get_quant_data(cons_el):
    """"""
    quant_out = {}
    for reporter in cons_el.findall('.//element'):
        quant_out[reporter.attrib['map']] = reporter.attrib['it']
    return quant_out
1199252
def rowCount(self, index=QModelIndex()):
        """"""
        if self.total_rows <= self.rows_loaded:
            return self.total_rows
        else:
            return self.rows_loaded
798164
def _get_salt_params():
    '''
    
    '''
    all_stats = __salt__['status.all_status']()
    all_grains = __salt__['grains.items']()
    params = {}
    try:
        params['name'] = all_grains['id']
        params['hostname'] = all_grains['host']
        if all_grains['kernel'] == 'Darwin':
            sd_os = {'code': 'mac', 'name': 'Mac'}
        else:
            sd_os = {'code': all_grains['kernel'].lower(), 'name': all_grains['kernel']}
        params['os'] = salt.utils.json.dumps(sd_os)
        params['cpuCores'] = all_stats['cpuinfo']['cpu cores']
        params['installedRAM'] = six.text_type(int(all_stats['meminfo']['MemTotal']['value']) / 1024)
        params['swapSpace'] = six.text_type(int(all_stats['meminfo']['SwapTotal']['value']) / 1024)
        params['privateIPs'] = salt.utils.json.dumps(all_grains['fqdn_ip4'])
        params['privateDNS'] = salt.utils.json.dumps(all_grains['fqdn'])
    except KeyError:
        pass

    return params
926605
def GetIcmpStatistics():
    """"""
    statistics = MIB_ICMP()
    _GetIcmpStatistics(byref(statistics))
    results = _struct_to_dict(statistics)
    del(statistics)
    return results
126344
def _dump_queue_stats(self):
        '''
        
        '''
        extras = {}
        keys = self.redis_conn.keys('*:*:queue')
        total_backlog = 0
        for key in keys:
            elements = key.split(":")
            spider = elements[0]
            domain = elements[1]
            spider = 'queue_' + spider

            if spider not in extras:
                extras[spider] = {}
                extras[spider]['spider_backlog'] = 0
                extras[spider]['num_domains'] = 0

            count = self.redis_conn.zcard(key)
            total_backlog += count
            extras[spider]['spider_backlog'] += count
            extras[spider]['num_domains'] += 1

        extras['total_backlog'] = total_backlog

        if not self.logger.json:
            self.logger.info('Queue Stats Dump:\n{0}'.format(
                    json.dumps(extras, indent=4, sort_keys=True)))
        else:
            self.logger.info('Queue Stats Dump', extra=extras)