views:

133

answers:

2

Possible Duplicate:
Getting CPU temperature using Python?

What is the simplest method of going about this? Also preferably in Celsius.

+3  A: 

There's no standard Python library for this, but on various platforms you may be able to use a Python bridge to a platform API to access this information.

For example on Windows this is available through the Windows Management Instrumentation (WMI) APIs, which are available to Python through the PyWin32 library. There is even a Python WMI library which wraps PyWin32 to provide a more convenient interface. To get the temperature you'll need to use one of these libraries to access the root/WMI namespace and the MSAcpi_ThermalZone Temperature class. This gives the temperature in tenths of a Kelvin, so you'll need to convert to Celsius by deducting 2732 and dividing by 10.

Not sure about about Linux or Mac I'm afraid, but there may be equivalent libraries you can use. A quick Google indicated that /proc/acpi/thermal_zone/THM/temperature may be what yoiu're after if your distro supports the proc virtual filesystem for accessing kernel information.

Simon Hibbs
A: 

On Linux, that info is in /proc/acpi/thermal_zone/

Nathan