Temperature once per second

Found thus script to monitor some temperatures, i would like to have an update of the temperatures once a second to put them in a graph.
Does someone know how to manage this?

Any help will be appreciated

import clr #package pythonnet, not clr
import shutil

#openhardwaremonitor_hwtypes = ['Mainboard','SuperIO','CPU','RAM','GpuNvidia','GpuAti','TBalancer','Heatmaster','HDD']
openhardwaremonitor_hwtypes = ['Mainboard','SuperIO','CPU','RAM','GpuNvidia','GpuAti','TBalancer','Heatmaster','HDD']
cputhermometer_hwtypes = ['Mainboard','SuperIO','CPU','GpuNvidia','GpuAti','TBalancer','Heatmaster','HDD']
openhardwaremonitor_sensortypes = ['Voltage','Clock','Temperature','Load','Fan','Flow','Control','Level','Factor','Power','Data','SmallData']
cputhermometer_sensortypes = ['Voltage','Clock','Temperature','Load','Fan','Flow','Control','Level']

def initialize_openhardwaremonitor():
    file = 'OpenHardwareMonitorLib.dll'

    from OpenHardwareMonitor import Hardware

    handle = Hardware.Computer()
    handle.MainboardEnabled = True
    handle.CPUEnabled = True
    handle.RAMEnabled = True
    handle.GPUEnabled = True
    handle.HDDEnabled = True
    return handle

def fetch_stats(handle):
    for i in handle.Hardware:
        for sensor in i.Sensors:
        for j in i.SubHardware:
            for subsensor in j.Sensors:

def parse_sensor(sensor):
        if sensor.Value is not None:
            if type(sensor).__module__ == 'OpenHardwareMonitor.Hardware':
                sensortypes = openhardwaremonitor_sensortypes
                hardwaretypes = openhardwaremonitor_hwtypes
                hardwaretypes = openhardwaremonitor_hwtypes

            if sensor.SensorType == sensortypes.index('Temperature'):
                print(u"%s %s Temperature Sensor #%i %s - %s\u00B0C" % (hardwaretypes[sensor.Hardware.HardwareType], sensor.Hardware.Name, sensor.Index, sensor.Name, sensor.Value))
if __name__ == "__main__":

    HardwareHandle = initialize_openhardwaremonitor()

Well, you could just call the script once a second.

Alternatively you could modify the main body (down the bottom) to call
fetch_stats() in a loop, with a time.sleep(1) between each call.

If the polling takes a significant amount of time compared to 1 second,
you might want to measure the amount if time fetch_stats() took by
comparing the value of time.time() with its value before the call,
then call time.sleep(t) with t being 1.0 minus the elapsed time. Or
compute the expect next time and subtract time.time() from that, which
could be more precise.

I would recommend using the csv module and modifying the print()
calls to write rows to a CSV file. You then have a nice simple table
which can be used to drive a graph.

Cameron Simpson cs@cskk.id.au

Thank you, just what I needed