def init(self):

        comp = Computer()

        for setting in OpenHardwareMonitor.SETTINGS:
            setattr(comp, setting, getattr(self, setting))

        comp.Open()
        self.__comp = comp
Beispiel #2
0
 def __init__(self, DLL=""):
     if DLL:
         clr.AddReference(DLL)
     else:
         clr.AddReference(os.getcwd() + r"\OpenHardwareMonitorLib.dll")
     from OpenHardwareMonitor.Hardware import Computer
     self.computer = Computer()
     self.computer.MainboardEnabled = True
     self.computer.CPUEnabled = True
     self.computer.HDDEnabled = True
     self.computer.RAMEnabled = True
     self.computer.GPUEnabled = True
     self.computer.Open(True)
     self.hardwares = Hardwares(self.computer)
Beispiel #3
0
def TempAware(DL):
    import clr  # the pythonnet module. You might need to install it 'pip install pythonnet'
    clr.AddReference(
        'TempAware\\OpenHardwareMonitorLib.dll')  #enter your dll path
    from OpenHardwareMonitor.Hardware import Computer
    tempature = 0
    colorplusdown = 0
    c = Computer()
    c.CPUEnabled = True  # get the Info about CPU
    c.GPUEnabled = True  # get the Info about GPU
    c.Open()
    for DName in range(0, len(c.Hardware)):
        if ("GPU" in str(c.Hardware[DName])) or ("gpu" in str(
                c.Hardware[DName])):
            while True:
                for Sen in range(0, (len(c.Hardware[DName].Sensors))):
                    if "temperature" in str(
                            c.Hardware[1].Sensors[Sen].Identifier):
                        tempature = (c.Hardware[1].Sensors[Sen].get_Value())
                        print(tempature)
                        c.Hardware[1].Update()
                        if 19 > tempature:
                            for Device in DL:
                                colorplusdown = (tempature) * 255 / 19
                                Device.set_color(
                                    RGBColor(int(0), int(0 + colorplusdown),
                                             int(255)))
                            time.sleep(1)
                        elif 38 > tempature >= 19:
                            for Device in DL:
                                colorplusdown = (tempature - 19) * 255 / 19
                                Device.set_color(
                                    RGBColor(int(0), int(255),
                                             int(255 - colorplusdown)))
                            time.sleep(1)
                        elif 57 > tempature >= 38:
                            for Device in DL:
                                colorplusdown = (tempature - 38) * 255 / 19
                                Device.set_color(
                                    RGBColor(int(0 + colorplusdown), int(255),
                                             int(0)))
                            time.sleep(1)
                        elif 76 >= tempature >= 57:
                            for Device in DL:
                                colorplusdown = (tempature - 57) * 255 / 10
                                Device.set_color(
                                    RGBColor(int(255),
                                             int(255 - colorplusdown), int(0)))
                            time.sleep(1)
Beispiel #4
0
class Monitor:
    HardwareType = ["Mainboard",
                    "SuperIO",
                    "CPU",
                    "GpuNvidia",
                    "GpuAti",
                    "TBalancer",
                    "Heatmaster",
                    "HDD"]
    SensorType = ["Voltage",
                  "Clock",
                  "Temperature",
                  "Load",
                  "Fan",
                  "Flow",
                  "Control",
                  "Level",
                  "Factor",
                  "Power",
                  "Data",
                  "SmallData"]
    
    def __init__(self, DLL=""):
        if DLL:
            clr.AddReference(DLL)
        else:
            clr.AddReference(os.getcwd() + r"\OpenHardwareMonitorLib.dll")
        from OpenHardwareMonitor.Hardware import Computer
        self.computer = Computer()
        self.computer.MainboardEnabled = True
        self.computer.CPUEnabled = True
        self.computer.HDDEnabled = True
        self.computer.RAMEnabled = True
        self.computer.GPUEnabled = True
        self.computer.Open(True)
        self.hardwares = Hardwares(self.computer)

    def get(self, hardware_name, _type_name=None):
        if _type_name is None:
            return self[hardware_name]
        try:
            return self[hardware_name][self.__translate(_type_name, 1)]
        except TypeError:
            return None

    def  __getitem__(self, index):
        self.hardwares.update(self.__translate(index))
        return self.hardwares[self.__translate(index)]

    def __translate(self, name, _type=0):
        return self.HardwareType.index(name) if not _type else self.SensorType.index(name)

    def info(self):
        for hardware in self.computer.Hardware:
            print(hardware.Name, self.HardwareType[hardware.HardwareType])
            hardware.Update()
            for sensor in hardware.Sensors:
                print(self.SensorType[sensor.get_SensorType()]+":", sensor.Name, sensor.Value)
Beispiel #5
0
def HardwareRemoved(hardware):
    print("Hardware removed!")


sensors = [
    '/intelcpu/0/temperature/0', '/intelcpu/0/temperature/1',
    '/intelcpu/0/temperature/2', '/intelcpu/0/temperature/3'
]

hardware = ['/intelcpu/0']

__sensors = []
__hw = []

comp = Computer()

comp.MainboardEnabled = False
comp.RAMEnabled = False
comp.CPUEnabled = True
comp.GPUEnabled = False
comp.HDDEnabled = False
comp.Open()

for hw in comp.Hardware:
    print(hw.Identifier, hardware)
    if str(hw.Identifier) in hardware:
        __hw.append(hw)

        hw.Update()
        for sensor in hw.Sensors:
Beispiel #6
0
import time
import configparser
import smtplib
import colorama
import os.path
import clr
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from Classes import MySQL, Send, config_class, Global
from colorama import Fore, Style

#------------------------------------dll reding-------------------------------
clr.AddReference(os.getcwd() + r'\OpenHardwareMonitorLib')
from OpenHardwareMonitor.Hardware import Computer

c = Computer()
c.GPUEnabled = True
c.Open()
#------------------------------------------------------------------------------

s = Send()
db = MySQL()  # connecting with database
config_class = config_class()

Gl = Global()
json_data = Gl.language()

#--------------------------config-settings-------------------------------------
config = configparser.ConfigParser()

if os.path.isfile('settings\config.ini') == True:
Beispiel #7
0
import time
import datetime
import wmi

if __name__ == "__main__":

    # w = wmi.WMI(namespace=r"D:\Tools\OpenHardwareMonitor")
    #
    # temperature_infos = w.Sensor()
    #
    # for sensor in temperature_infos:
    #     if sensor.SensorType == u'Temperature':
    #         print(sensor.Name)
    #         print(sensor.Value)

    import clr  # the pythonnet module.
    clr.AddReference(r'YourdllPath')
    # e.g. clr.AddReference(r'OpenHardwareMonitor/OpenHardwareMonitorLib'), without .dll

    from OpenHardwareMonitor.Hardware import Computer

    c = Computer()
    c.CPUEnabled = True  # get the Info about CPU
    c.GPUEnabled = True  # get the Info about GPU
    c.Open()
    while True:
        for a in range(0, len(c.Hardware[0].Sensors)):
            # print(c.Hardware[0].Sensors[a].Identifier)
            if "/temperature" in str(c.Hardware[0].Sensors[a].Identifier):
                print(c.Hardware[0].Sensors[a].get_Value())
                c.Hardware[0].Update()
Beispiel #8
0
from OpenHardwareMonitor.Hardware import Computer

# pyinstaller --onefile --windowed --uac-admin SerialTest.py

#GUI INIT
root = Tk()
root.title("Info Display Serial Server")
S = Scrollbar(root)
S.pack(side=RIGHT, fill=Y)
T = Text(root, height=50, width=100)
S.config(command=T.yview)
T.pack()
T.config(yscrollcommand=S.set)

#Configure Open Hardware Lib
c = Computer()
c.CPUEnabled = True  # get the Info about CPU
c.GPUEnabled = True  # get the Info about GPU
c.MainboardEnabled = True
c.FanControllerEnabled = True
c.HDDEnabled = True
c.RAMEnabled = True
c.Open()

#Message Send Delay, we could sent multiple commands with same message but we are lazy and only sent one command with every message, this is the time between the messages
#crappy com structure but works
MsgDelay = 0.15

#Settings for Serial Interface
ser = serial.Serial()
ser.baudrate = 115200
Beispiel #9
0
import sys
import time
import clr

sys.path.append(r"D:\Github\Repositories\arduino\cpuinfo")
clr.AddReference("OpenHardwareMonitorLib")
from OpenHardwareMonitor.Hardware import Computer

computer = Computer()
computer.CPUEnabled = True
computer.Open()
# print(computer.Hardware[0].Identifier)
# print(computer.Hardware[0].Sensors)

while True:
    for a in range(0, len(computer.Hardware[0].Sensors)):
        # print(a)
        # print(computer.Hardware[0].Sensors[a].Identifier)
        if str(computer.Hardware[0].Sensors[a].Identifier
               ) == "/intelcpu/0/temperature/4":
            print(computer.Hardware[0].Sensors[a].Value)
    computer.Hardware[0].Update()
    time.sleep(1)
    # print("=================")
Beispiel #10
0
import clr
import time
clr.AddReference("C:/Users/63450/Desktop/毕业实习/day1/OpenHardwareMonitorLib.dll"
                 )  #加载C#的库这个库网上可以下载
from OpenHardwareMonitor.Hardware import Computer
computer_tmp = Computer()  #实例这这个类

computer_tmp.CPUEnabled = True
computer_tmp.GPUEnabled = True  #获取GPU温度时用
computer_tmp.HDDEnabled = True
computer_tmp.RAMEnabled = True  #获取内存温度时用

computer_tmp.Open()

print(computer_tmp.Hardware[0].Identifier)
print(computer_tmp.Hardware[0].Sensors)
while True:
    for a in range(0, len(computer_tmp.Hardware[0].Sensors)):
        #print computer_tmp.Hardware[0].Sensors[a].Identifier
        if str(computer_tmp.Hardware[0].Sensors[a].Identifier
               ) == "/intelcpu/0/temperature/4":
            print(computer_tmp.Hardware[0].Sensors[a].Value)
            computer_tmp.Hardware[0].Update()
    time.sleep(1)