当前位置: 首页>>代码示例>>Python>>正文


Python psutil.sensors_fans方法代码示例

本文整理汇总了Python中psutil.sensors_fans方法的典型用法代码示例。如果您正苦于以下问题:Python psutil.sensors_fans方法的具体用法?Python psutil.sensors_fans怎么用?Python psutil.sensors_fans使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在psutil的用法示例。


在下文中一共展示了psutil.sensors_fans方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_emulate_data

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import sensors_fans [as 别名]
def test_emulate_data(self):
        def open_mock(name, *args, **kwargs):
            if name.endswith('/name'):
                return io.StringIO(u("name"))
            elif name.endswith('/fan1_label'):
                return io.StringIO(u("label"))
            elif name.endswith('/fan1_input'):
                return io.StringIO(u("2000"))
            else:
                return orig_open(name, *args, **kwargs)

        orig_open = open
        patch_point = 'builtins.open' if PY3 else '__builtin__.open'
        with mock.patch(patch_point, side_effect=open_mock):
            with mock.patch('glob.glob',
                            return_value=['/sys/class/hwmon/hwmon2/fan1']):
                fan = psutil.sensors_fans()['name'][0]
                self.assertEqual(fan.label, 'label')
                self.assertEqual(fan.current, 2000)


# =====================================================================
# --- test process
# ===================================================================== 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:26,代码来源:test_linux.py

示例2: test_sensors_fans

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import sensors_fans [as 别名]
def test_sensors_fans(self):
        self.execute(psutil.sensors_fans)

    # --- others 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:6,代码来源:test_memory_leaks.py

示例3: test_sensors_fans

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import sensors_fans [as 别名]
def test_sensors_fans(self):
        self.assertEqual(hasattr(psutil, "sensors_fans"), LINUX) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:4,代码来源:test_contracts.py

示例4: test_sensors_fans

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import sensors_fans [as 别名]
def test_sensors_fans(self):
        fans = psutil.sensors_fans()
        for name, entries in fans.items():
            self.assertIsInstance(name, str)
            for entry in entries:
                self.assertIsInstance(entry.label, str)
                self.assertIsInstance(entry.current, (int, long))
                self.assertGreaterEqual(entry.current, 0) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:10,代码来源:test_system.py

示例5: test_fans

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import sensors_fans [as 别名]
def test_fans(self):
        if not psutil.sensors_fans():
            self.skipTest("no fans")
        self.assert_stdout('fans.py') 
开发者ID:giampaolo,项目名称:psutil,代码行数:6,代码来源:test_misc.py

示例6: main

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import sensors_fans [as 别名]
def main():
    if not hasattr(psutil, "sensors_fans"):
        return sys.exit("platform not supported")
    fans = psutil.sensors_fans()
    if not fans:
        print("no fans detected")
        return
    for name, entries in fans.items():
        print(name)
        for entry in entries:
            print("    %-20s %s RPM" % (entry.label or name, entry.current))
        print() 
开发者ID:giampaolo,项目名称:psutil,代码行数:14,代码来源:fans.py

示例7: __init__

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import sensors_fans [as 别名]
def __init__(self):
        if not hasattr(psutil, "sensors_fans"):
            self.is_available = False
            logging.debug("Fans sensors is not available from psutil")
            return

        Source.__init__(self)

        self.name = 'Fan'
        self.measurement_unit = 'RPM'
        self.pallet = ('fan light', 'fan dark',
                       'fan light smooth', 'fan dark smooth')

        sensors_dict = dict()
        try:
            sensors_dict = psutil.sensors_fans()
        except IOError:
            logging.debug("Unable to create sensors dict")
            self.is_available = False
            return
        if not sensors_dict:
            self.is_available = False
            return

        for key, value in sensors_dict.items():
            sensor_name = key
            for sensor_idx, sensor in enumerate(value):
                sensor_label = sensor.label

                full_name = ""
                if not sensor_label:
                    full_name = sensor_name + "," + str(sensor_idx)
                else:
                    full_name = sensor_label

                logging.debug("Fan sensor name %s", full_name)

                self.available_sensors.append(full_name)

        self.last_measurement = [0] * len(self.available_sensors) 
开发者ID:amanusk,项目名称:s-tui,代码行数:42,代码来源:fan_source.py

示例8: update

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import sensors_fans [as 别名]
def update(self):
        sample = psutil.sensors_fans()
        self.last_measurement = []
        for sensor in sample.values():
            for minor_sensor in sensor:
                self.last_measurement.append(int(minor_sensor.current)) 
开发者ID:amanusk,项目名称:s-tui,代码行数:8,代码来源:fan_source.py

示例9: sensors_fan

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import sensors_fans [as 别名]
def sensors_fan(self, sensor: Optional[str] = None) -> SensorResponseList:
        """
        Get stats from the fan sensors.

        :param sensor: Select the sensor name.
        :return: List of :class:`platypush.message.response.system.SensorFanResponse`.
        """
        import psutil
        stats = psutil.sensors_fans()

        def _expand_stats(name, _stats):
            return SensorResponseList([
                SensorFanResponse(
                    name=name,
                    current=s.current,
                    label=s.label,
                )
                for s in _stats
            ])

        if sensor:
            stats = [addr for name, addr in stats.items() if name == sensor]
            assert stats, 'No such sensor name: {}'.format(sensor)
            return _expand_stats(sensor, stats[0])

        return SensorResponseList([
            _expand_stats(name, stat)
            for name, stat in stats.items()
        ]) 
开发者ID:BlackLight,项目名称:platypush,代码行数:31,代码来源:__init__.py

示例10: main

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import sensors_fans [as 别名]
def main():
    if hasattr(psutil, "sensors_temperatures"):
        temps = psutil.sensors_temperatures()
    else:
        temps = {}
    if hasattr(psutil, "sensors_fans"):
        fans = psutil.sensors_fans()
    else:
        fans = {}
    if hasattr(psutil, "sensors_battery"):
        battery = psutil.sensors_battery()
    else:
        battery = None

    if not any((temps, fans, battery)):
        print("can't read any temperature, fans or battery info")
        return

    names = set(list(temps.keys()) + list(fans.keys()))
    for name in names:
        print(name)
        # Temperatures.
        if name in temps:
            print("    Temperatures:")
            for entry in temps[name]:
                print("        %-20s %s°C (high=%s°C, critical=%s°C)" % (
                    entry.label or name, entry.current, entry.high,
                    entry.critical))
        # Fans.
        if name in fans:
            print("    Fans:")
            for entry in fans[name]:
                print("        %-20s %s RPM" % (
                    entry.label or name, entry.current))

    # Battery.
    if battery:
        print("Battery:")
        print("    charge:     %s%%" % round(battery.percent, 2))
        if battery.power_plugged:
            print("    status:     %s" % (
                "charging" if battery.percent < 100 else "fully charged"))
            print("    plugged in: yes")
        else:
            print("    left:       %s" % secs2hours(battery.secsleft))
            print("    status:     %s" % "discharging")
            print("    plugged in: no") 
开发者ID:giampaolo,项目名称:psutil,代码行数:49,代码来源:sensors.py


注:本文中的psutil.sensors_fans方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。