Operation: Get CPC Energy Management Data (any CPC mode).
356142
def get(method, hmc, uri, uri_parms, logon_required):
        """"""
        cpc_oid = uri_parms[0]
        try:
            cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
        except KeyError:
            raise InvalidResourceError(method, uri)

        energy_props = {
            'cpc-power-cap-allowed':
                cpc.properties.get('cpc-power-cap-allowed'),
            'cpc-power-cap-current':
                cpc.properties.get('cpc-power-cap-current'),
            'cpc-power-cap-maximum':
                cpc.properties.get('cpc-power-cap-maximum'),
            'cpc-power-cap-minimum':
                cpc.properties.get('cpc-power-cap-minimum'),
            'cpc-power-capping-state':
                cpc.properties.get('cpc-power-capping-state'),
            'cpc-power-consumption':
                cpc.properties.get('cpc-power-consumption'),
            'cpc-power-rating':
                cpc.properties.get('cpc-power-rating'),
            'cpc-power-save-allowed':
                cpc.properties.get('cpc-power-save-allowed'),
            'cpc-power-saving':
                cpc.properties.get('cpc-power-saving'),
            'cpc-power-saving-state':
                cpc.properties.get('cpc-power-saving-state'),
            'zcpc-ambient-temperature':
                cpc.properties.get('zcpc-ambient-temperature'),
            'zcpc-dew-point':
                cpc.properties.get('zcpc-dew-point'),
            'zcpc-exhaust-temperature':
                cpc.properties.get('zcpc-exhaust-temperature'),
            'zcpc-heat-load':
                cpc.properties.get('zcpc-heat-load'),
            'zcpc-heat-load-forced-air':
                cpc.properties.get('zcpc-heat-load-forced-air'),
            'zcpc-heat-load-water':
                cpc.properties.get('zcpc-heat-load-water'),
            'zcpc-humidity':
                cpc.properties.get('zcpc-humidity'),
            'zcpc-maximum-potential-heat-load':
                cpc.properties.get('zcpc-maximum-potential-heat-load'),
            'zcpc-maximum-potential-power':
                cpc.properties.get('zcpc-maximum-potential-power'),
            'zcpc-power-cap-allowed':
                cpc.properties.get('zcpc-power-cap-allowed'),
            'zcpc-power-cap-current':
                cpc.properties.get('zcpc-power-cap-current'),
            'zcpc-power-cap-maximum':
                cpc.properties.get('zcpc-power-cap-maximum'),
            'zcpc-power-cap-minimum':
                cpc.properties.get('zcpc-power-cap-minimum'),
            'zcpc-power-capping-state':
                cpc.properties.get('zcpc-power-capping-state'),
            'zcpc-power-consumption':
                cpc.properties.get('zcpc-power-consumption'),
            'zcpc-power-rating':
                cpc.properties.get('zcpc-power-rating'),
            'zcpc-power-save-allowed':
                cpc.properties.get('zcpc-power-save-allowed'),
            'zcpc-power-saving':
                cpc.properties.get('zcpc-power-saving'),
            'zcpc-power-saving-state':
                cpc.properties.get('zcpc-power-saving-state'),
        }
        cpc_data = {
            'error-occurred': False,
            'object-uri': cpc.uri,
            'object-id': cpc.oid,
            'class': 'cpcs',
            'properties': energy_props,
        }
        result = {'objects': [cpc_data]}

        return result
705308
def check_power(self):
    """"""
    state = self.check_power_raw()
    data = {}
    data['s1'] = bool(state & 0x01)
    data['s2'] = bool(state & 0x02)
    data['s3'] = bool(state & 0x04)
    data['s4'] = bool(state & 0x08)
    return data
251415
def get_tpm_status(d_info):
    

    # note:
    # Get TPM support status : ipmi cmd '0xF5', valid flags '0xC0'
    #
    # $ ipmitool raw 0x2E 0xF5 0x80 0x28 0x00 0x81 0xC0
    #
    # Raw response:
    # 80 28 00 C0 C0: True
    # 80 28 00 -- --: False (other values than 'C0 C0')

    ipmicmd = ipmi_command.Command(bmc=d_info['irmc_address'],
                                   userid=d_info['irmc_username'],
                                   password=d_info['irmc_password'])
    try:
        response = _send_raw_command(ipmicmd, GET_TPM_STATUS)
        if response['code'] != 0:
            raise IPMIFailure(
                "IPMI operation '%(operation)s' failed: %(error)s" %
                {'operation': "GET TMP status",
                 'error': response.get('error')})
        out = ' '.join('{:02X}'.format(x) for x in response['data'])
        return out is not None and out[-5:] == 'C0 C0'

    except ipmi_exception.IpmiException as e:
        raise IPMIFailure(
            "IPMI operation '%(operation)s' failed: %(error)s" %
            {'operation': "GET TMP status", 'error': e})
292885
def get_electricity_info(self, apart_id, meter_room):
        
        apart_id = str(apart_id)
        meter_room = str(meter_room)
        try:
            content = LifeService._get_electricity_info_html(apart_id, meter_room)
        except KeyError as e:
            _.d(e.message)
            result = {
                'response': None
            }
            return _.to_json_string(result)
        soup = BeautifulSoup(content)
        tags = soup.find_all(name='span', class_='STYLE7')
        result = {
            'response': {
                'apart': _.trim(tags[0].string),
                'apart_id': _.trim(tags[1].string),
                'used': _.trim(tags[2].string),
                'left': _.trim(tags[3].string),
                'update_time': _.trim(tags[4].string)
            }
        }
        return _.to_json_string(result)
406912
def get(cls, *args, **kwargs):
        """"""

        from indico_piwik.plugin import PiwikPlugin

        if not PiwikPlugin.settings.get('cache_enabled'):
            return cls(*args, **kwargs).to_serializable()

        cache = GenericCache('Piwik.Report')
        key = u'{}-{}-{}'.format(cls.__name__, args, kwargs)

        report = cache.get(key)
        if not report:
            report = cls(*args, **kwargs)
            cache.set(key, report, PiwikPlugin.settings.get('cache_ttl'))
        return report.to_serializable()
481955
def get_context_data(self, **kwargs):
        """"""
        data = super(GaugesView, self).get_context_data(**kwargs)
        data.update({'gauges': get_r().gauge_slugs()})
        return data
262019
def _get_table_data(self):
        """"""
        data = self._simplify_shape(
                self.table_widget.get_data())
        if self.table_widget.array_btn.isChecked():
            return array(data)
        elif pd and self.table_widget.df_btn.isChecked():
            info = self.table_widget.pd_info
            buf = io.StringIO(self.table_widget.pd_text)
            return pd.read_csv(buf, **info)
        return data
1224452
def power_source_str(self):
        """"""
        if DeviceInfo.ATTR_POWER_SOURCE not in self.raw:
            return None
        return DeviceInfo.VALUE_POWER_SOURCES.get(self.power_source, 'Unknown')
1330179
def __get_percpu(self):
        """"""
        # Never update more than 1 time per cached_time
        if self.timer_percpu.finished():
            self.percpu_percent = []
            for cpu_number, cputimes in enumerate(psutil.cpu_times_percent(interval=0.0, percpu=True)):
                cpu = {'key': self.get_key(),
                       'cpu_number': cpu_number,
                       'total': round(100 - cputimes.idle, 1),
                       'user': cputimes.user,
                       'system': cputimes.system,
                       'idle': cputimes.idle}
                # The following stats are for API purposes only
                if hasattr(cputimes, 'nice'):
                    cpu['nice'] = cputimes.nice
                if hasattr(cputimes, 'iowait'):
                    cpu['iowait'] = cputimes.iowait
                if hasattr(cputimes, 'irq'):
                    cpu['irq'] = cputimes.irq
                if hasattr(cputimes, 'softirq'):
                    cpu['softirq'] = cputimes.softirq
                if hasattr(cputimes, 'steal'):
                    cpu['steal'] = cputimes.steal
                if hasattr(cputimes, 'guest'):
                    cpu['guest'] = cputimes.guest
                if hasattr(cputimes, 'guest_nice'):
                    cpu['guest_nice'] = cputimes.guest_nice
                # Append new CPU to the list
                self.percpu_percent.append(cpu)
                # Reset timer for cache
                self.timer_percpu = Timer(self.cached_time)
        return self.percpu_percent
409506
def _GetStat(self):
    
    stat_object = super(CPIOFileEntry, self)._GetStat()

    # File data stat information.
    stat_object.size = getattr(
        self._cpio_archive_file_entry, 'data_size', None)

    # Ownership and permissions stat information.
    mode = getattr(self._cpio_archive_file_entry, 'mode', 0)
    stat_object.mode = stat.S_IMODE(mode)
    stat_object.uid = getattr(
        self._cpio_archive_file_entry, 'user_identifier', None)
    stat_object.gid = getattr(
        self._cpio_archive_file_entry, 'group_identifier', None)

    return stat_object
951548
def load_energy():
    """"""
    tbl_name = 'energy_usage'
    data = get_example_data('energy.json.gz')
    pdf = pd.read_json(data)
    pdf.to_sql(
        tbl_name,
        db.engine,
        if_exists='replace',
        chunksize=500,
        dtype={
            'source': String(255),
            'target': String(255),
            'value': Float(),
        },
        index=False)

    print('Creating table [wb_health_population] reference')
    tbl = db.session.query(TBL).filter_by(table_name=tbl_name).first()
    if not tbl:
        tbl = TBL(table_name=tbl_name)
    tbl.description = 'Energy consumption'
    tbl.database = utils.get_or_create_main_db()

    if not any(col.metric_name == 'sum__value' for col in tbl.metrics):
        tbl.metrics.append(SqlMetric(
            metric_name='sum__value',
            expression='SUM(value)',
        ))

    db.session.merge(tbl)
    db.session.commit()
    tbl.fetch_metadata()

    slc = Slice(
        slice_name='Energy Sankey',
        viz_type='sankey',
        datasource_type='table',
        datasource_id=tbl.id,
        params=textwrap.dedent("""\
        {
            "collapsed_fieldsets": "",
            "groupby": [
                "source",
                "target"
            ],
            "having": "",
            "metric": "sum__value",
            "row_limit": "5000",
            "slice_name": "Energy Sankey",
            "viz_type": "sankey",
            "where": ""
        }
        """),
    )
    misc_dash_slices.add(slc.slice_name)
    merge_slice(slc)

    slc = Slice(
        slice_name='Energy Force Layout',
        viz_type='directed_force',
        datasource_type='table',
        datasource_id=tbl.id,
        params=textwrap.dedent("""\
        {
            "charge": "-500",
            "collapsed_fieldsets": "",
            "groupby": [
                "source",
                "target"
            ],
            "having": "",
            "link_length": "200",
            "metric": "sum__value",
            "row_limit": "5000",
            "slice_name": "Force",
            "viz_type": "directed_force",
            "where": ""
        }
        """),
    )
    misc_dash_slices.add(slc.slice_name)
    merge_slice(slc)

    slc = Slice(
        slice_name='Heatmap',
        viz_type='heatmap',
        datasource_type='table',
        datasource_id=tbl.id,
        params=textwrap.dedent("""\
        {
            "all_columns_x": "source",
            "all_columns_y": "target",
            "canvas_image_rendering": "pixelated",
            "collapsed_fieldsets": "",
            "having": "",
            "linear_color_scheme": "blue_white_yellow",
            "metric": "sum__value",
            "normalize_across": "heatmap",
            "slice_name": "Heatmap",
            "viz_type": "heatmap",
            "where": "",
            "xscale_interval": "1",
            "yscale_interval": "1"
        }
        """),
    )
    misc_dash_slices.add(slc.slice_name)
    merge_slice(slc)
530144
async def get_reports(self):
        
        cmd = OTGW_CMD_REPORT
        reports = {}
        for value in OTGW_REPORTS.keys():
            ret = await self._wait_for_cmd(cmd, value)
            if ret is None:
                reports[value] = None
                continue
            reports[value] = ret[2:]
        status = {
            OTGW_ABOUT: reports.get(OTGW_REPORT_ABOUT),
            OTGW_BUILD: reports.get(OTGW_REPORT_BUILDDATE),
            OTGW_CLOCKMHZ: reports.get(OTGW_REPORT_CLOCKMHZ),
            OTGW_MODE: reports.get(OTGW_REPORT_GW_MODE),
            OTGW_SMART_PWR: reports.get(OTGW_REPORT_SMART_PWR),
            OTGW_THRM_DETECT: reports.get(OTGW_REPORT_THERMOSTAT_DETECT),
            OTGW_DHW_OVRD: reports.get(OTGW_REPORT_DHW_SETTING),
        }
        ovrd_mode = reports.get(OTGW_REPORT_SETPOINT_OVRD)
        if ovrd_mode is not None:
            ovrd_mode = str.upper(ovrd_mode[0])
            status.update({OTGW_SETP_OVRD_MODE: ovrd_mode})
        gpio_funcs = reports.get(OTGW_REPORT_GPIO_FUNCS)
        if gpio_funcs is not None:
            status.update({
                OTGW_GPIO_A: int(gpio_funcs[0]),
                OTGW_GPIO_B: int(gpio_funcs[1]),
            })
        led_funcs = reports.get(OTGW_REPORT_LED_FUNCS)
        if led_funcs is not None:
            status.update({
                OTGW_LED_A: led_funcs[0],
                OTGW_LED_B: led_funcs[1],
                OTGW_LED_C: led_funcs[2],
                OTGW_LED_D: led_funcs[3],
                OTGW_LED_E: led_funcs[4],
                OTGW_LED_F: led_funcs[5],
            })
        tweaks = reports.get(OTGW_REPORT_TWEAKS)
        if tweaks is not None:
            status.update({
                OTGW_IGNORE_TRANSITIONS: int(tweaks[0]),
                OTGW_OVRD_HB: int(tweaks[1]),
            })
        sb_temp = reports.get(OTGW_REPORT_SETBACK_TEMP)
        if sb_temp is not None:
            status.update({OTGW_SB_TEMP: float(sb_temp)})
        vref = reports.get(OTGW_REPORT_VREF)
        if vref is not None:
            status.update({OTGW_VREF: int(vref)})
        if (ovrd_mode is not None and ovrd_mode != OTGW_SETP_OVRD_DISABLED):
            status[DATA_ROOM_SETPOINT_OVRD] = float(
                reports[OTGW_REPORT_SETPOINT_OVRD][1:])
        self._update_status(status)
        return dict(self._protocol.status)
177462
async def get_power_parameters(self):
        """"""
        data = await self._handler.power_parameters(system_id=self.system_id)
        return data
502829
def get_data(self):
        """"""
        url = self.build_url()
        self.locationApiData = requests.get(url)
        if not self.locationApiData.status_code == 200:
            raise self.locationApiData.raise_for_status()
496446
private function _info()
    {
        foreach ($this->_output as $ups) {

            $dev = new UPSDevice();

            // General info
            $dev->setName("EVER");
            $dev->setMode("PowerSoftPlus");
            $maxpwr = 0;
            $load = null;
            if (preg_match('/^Identifier: UPS Model\s*:\s*(.*)$/m', $ups, $data)) {
                $dev->setModel(trim($data[1]));
                if (preg_match('/\s(\d*)[^\d]*$/', trim($data[1]), $number)) {
                    $maxpwr=$number[1]*0.65;
                }
            }
            if (preg_match('/^Current UPS state\s*:\s*(.*)$/m', $ups, $data)) {
                $dev->setStatus(trim($data[1]));
            }
            if (preg_match('/^Output load\s*:\s*(.*)\s\[\%\]$/m', $ups, $data)) {
               $load = trim($data[1]);
            }
            //wrong Output load issue
            if (($load == 0) && ($maxpwr != 0) && preg_match('/^Effective power\s*:\s*(.*)\s\[W\]$/m', $ups, $data)) {
                $load = 100.0*trim($data[1])/$maxpwr;
            }
            if ($load != null) {
                $dev->setLoad($load);
            }
            // Battery
            if (preg_match('/^Battery voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) {
                $dev->setBatteryVoltage(trim($data[1]));
            }
            if (preg_match('/^Battery state\s*:\s*(.*)$/m', $ups, $data)) {
                if (preg_match('/^At full capacity$/', trim($data[1]))) {
                    $dev->setBatterCharge(100);
                } elseif (preg_match('/^(Discharged)|(Depleted)$/', trim($data[1]))) {
                    $dev->setBatterCharge(0);
                }
            }
            // Line
            if (preg_match('/^Input voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) {
                $dev->setLineVoltage(trim($data[1]));
            }
            if (preg_match('/^Input frequency\s*:\s*(.*)\s\[Hz\]$/m', $ups, $data)) {
                $dev->setLineFrequency(trim($data[1]));
            }
            $this->upsinfo->setUpsDevices($dev);
        }
    }
1133426
def get_installed_power(self):
        

        """
        for wind_farm in self.wind_farms:
            wind_farm.installed_power = wind_farm.get_installed_power()
        return sum(wind_farm.installed_power for wind_farm in self.wind_farms)
725744
def power_on(self):
        """"""
        payload = amt.wsman.power_state_request(self.uri, "on")
        return self.post(payload, CIM_PowerManagementService)