› Foros › PC › Software libre
import wmi
w = wmi.WMI()
print w.Win32_TemperatureProbe()[0].CurrentReading
w = wmi.WMI(namespace="root\wmi")
temperature_info = w.MSAcpi_ThermalZoneTemperature()[0]
print temperature_info.CurrentTemperature
import wmi
def hdd_temp():
TEMPATTR = 194 # the number of the temperature attribute
c = wmi.WMI(namespace='root/wmi')
for drive in c.MSStorageDriver_ATAPISmartData():
# strip out parts of the name to make it more readable.
driveName = drive.InstanceName.split('_')[1]
# The first byte of the array is the number of 12-byte 'blocks' it contains.
blockNum = drive.VendorSpecific[0]
# Split the rest of the array into blocks.
vs = drive.VendorSpecific[1:]
blocks = [vs[i*12:i*12+12] for i in xrange(blockNum)]
# Find the temperature block for each drive and print the value.
print driveName + ':',
for block in blocks:
if block[1] == TEMPATTR:
print str(block[6]) + unichr(176).encode("cp850") + 'C'
return str(block[6])
break
hdd_temp()
Korso10 escribió:Yo medía las temperaturas de los discos duros así:import wmi
def hdd_temp():
TEMPATTR = 194 # the number of the temperature attribute
c = wmi.WMI(namespace='root/wmi')
for drive in c.MSStorageDriver_ATAPISmartData():
# strip out parts of the name to make it more readable.
driveName = drive.InstanceName.split('_')[1]
# The first byte of the array is the number of 12-byte 'blocks' it contains.
blockNum = drive.VendorSpecific[0]
# Split the rest of the array into blocks.
vs = drive.VendorSpecific[1:]
blocks = [vs[i*12:i*12+12] for i in xrange(blockNum)]
# Find the temperature block for each drive and print the value.
print driveName + ':',
for block in blocks:
if block[1] == TEMPATTR:
print str(block[6]) + unichr(176).encode("cp850") + 'C'
return str(block[6])
break
hdd_temp()
Y sí, tienes que usar wmi, pero no me preguntes mucho más, que no me acuerdo de mucho A mí me ayudaron bastante en stackoverflow, por si te sirve.
...
wmi.x_wmi: <x_wmi: Unexpected COM Error (-2147217396, 'OLE error 0x8004100c', None, None>>