Ejemplo n.º 1
0
    def __init__(self, device=None, sensor=None, cpu=True, ram=False, gpu=False, mobo=False, disk=False):
        self.__handle = Hardware.Computer()
        self.__handle.CPUEnabled = cpu
        self.__handle.MainboardEnabled = mobo
        self.__handle.RAMEnabled = ram
        self.__handle.GPUEnabled = gpu
        self.__handle.HDDEnabled = disk
        self.__handle.Open()
        
        if len(self.__handle.Hardware) < 1:
            raise Exception("No hardware was detected")

        try:
            self.__hardware = next(h for h in self.__handle.Hardware if h.Name == device)
        except:
            raise Exception("Device '%s' not detected.\r\n\r\nAvailable devices:\r\n%s"
                            %(device, '\r\n'.join(sorted(f"- {h.Name}" for h in self.__handle.Hardware))))
            
        # Poll device
        self.__hardware.Update()

        try:
            self.__sensor = next(s for s in self.__hardware.Sensors if s.SensorType == 2 and s.Name == sensor)
        except:
            raise Exception("Sensor '%s' not found.\r\n\r\nAvailable sensors:\r\n%s"
                            %(sensor, '\r\n'.join(sorted(f"- {s.Name}" for s in self.__hardware.Sensors if s.SensorType == 2))))
        
        self.value = self.__sensor.Value
Ejemplo n.º 2
0
def init_OHM() :
 clr.AddReference(os.getcwd() + R'\OpenHardwareMonitorLib.dll')
 from OpenHardwareMonitor import Hardware
 hw = Hardware.Computer()
 hw.MainboardEnabled, hw.CPUEnabled, hw.RAMEnabled, hw.GPUEnabled, hw.HDDEnabled = True, True, True, True, True
 hw.Open()
 return hw
Ejemplo n.º 3
0
    def __init__(self, path, sleep):
        """
        Small module to monitor the local hardware.

        Args:
            path:   path to dump the measurements to
            sleep:  time between measurements
        """
        handle = Hardware.Computer()
        handle.MainboardEnabled = True
        handle.CPUEnabled = True
        handle.RAMEnabled = True
        handle.GPUEnabled = True
        handle.HDDEnabled = True
        handle.Open()
        self.handle = handle

        self.hwtypes = [
            'Mainboard', 'SuperIO', 'CPU', 'RAM', 'GpuNvidia', 'GpuAti',
            'TBalancer', 'Heatmaster', 'HDD'
        ]
        self.sensortypes = [
            'Voltage', 'Clock', 'Temperature', 'Load', 'Fan', 'Flow',
            'Control', 'Level', 'Factor', 'Power', 'Data', 'SmallData'
        ]
        self.measurements = None
        self.path = path
        self.sleep = sleep
        self.terminate_flag = False
Ejemplo n.º 4
0
 def init_OHM(self, pathDll):
     clr.AddReference(pathDll)
     from OpenHardwareMonitor import Hardware
     hw = Hardware.Computer()
     hw.MainboardEnabled, hw.CPUEnabled, hw.RAMEnabled, hw.GPUEnabled, hw.HDDEnabled = False, True, False, False, False
     hw.Open()
     return hw
Ejemplo n.º 5
0
def initialize_cputhermometer():
    file = 'D:\git\prototype\Temp_UI\CPUThermometerLib.dll'
    clr.AddReference(file)

    from CPUThermometer import Hardware
    handle = Hardware.Computer()
    handle.CPUEnabled = True
    handle.Open()
    return handle
Ejemplo n.º 6
0
    def __init__(self):
        self.OHWM = OPH_Hardware.Computer()
        self.OHWM.CPUEnabled = settings.CPUEnabled
        self.OHWM.RAMEnabled = settings.RAMEnabled
        self.OHWM.GPUEnabled = settings.GPUEnabled
        self.OHWM.HDDEnabled = settings.HDDEnabled
        self.OHWM.MainboardEnabled = settings.MainboardEnabled

        self.OHWM.Open()
Ejemplo n.º 7
0
def init_OHM():
    clr.AddReference(
        os.path.abspath(os.path.dirname(__file__)) +
        R'\OpenHardwareMonitorLib.dll')
    from OpenHardwareMonitor import Hardware
    hw = Hardware.Computer()
    hw.MainboardEnabled, hw.CPUEnabled, hw.RAMEnabled, hw.GPUEnabled, hw.HDDEnabled = True, True, True, True, True
    hw.Open()
    return hw
Ejemplo n.º 8
0
 def initialize_cputhermometer(self):
     file = 'CPUThermometerLib'
     clr.AddReference(file)
 
     from CPUThermometer import Hardware
     handle = Hardware.Computer()
     handle.CPUEnabled = True
     handle.Open()
     return handle
Ejemplo n.º 9
0
    def initialize_openhardwaremonitor(self):
        """Incializa a lib retornando o objeto Computer"""
        pythonnet.AddReference(self._lib)

        from OpenHardwareMonitor import Hardware

        handle = Hardware.Computer()
        handle.GPUEnabled = True
        handle.Open()
        return handle
Ejemplo n.º 10
0
 def initialize_openhardwaremonitor():
     clr.AddReference(ohwm_dll)
     from OpenHardwareMonitor import Hardware
     handle = Hardware.Computer()
     handle.MainboardEnabled = True
     handle.CPUEnabled = True
     handle.RAMEnabled = True
     handle.GPUEnabled = True
     handle.HDDEnabled = True
     handle.Open()
     return handle
Ejemplo n.º 11
0
    def init_ohm(self):
        """Initialize sensors object from OpenHardwareMonitorLib.dll"""
        AddReference('OpenHardwareMonitorLib')
        from OpenHardwareMonitor import Hardware

        self.handle = Hardware.Computer()
        self.handle.MainboardEnabled = True
        self.handle.CPUEnabled = True
        self.handle.RAMEnabled = True
        self.handle.GPUEnabled = True
        self.handle.HDDEnabled = True
        self.handle.Open()
Ejemplo n.º 12
0
def initialize_openhardwaremonitor():
    clr.AddReference(resource_path('OpenHardwareMonitorLib.dll'))
    from OpenHardwareMonitor import Hardware
    handle = Hardware.Computer()
    handle.CPUEnabled = True
    handle.RAMEnabled = True
    handle.GPUEnabled = True
    IsCpuEnabled = True
    IsGpuEnabled = True
    IsMemoryEnabled = True
    handle.Open()
    return handle
Ejemplo n.º 13
0
    def init_open_hw_monitor(self):
        clr.AddReference(DLL_PATH)

        from OpenHardwareMonitor import Hardware

        handle = Hardware.Computer()
        handle.MainboardEnabled = True
        handle.CPUEnabled = True
        handle.RAMEnabled = True
        handle.GPUEnabled = True
        handle.HDDEnabled = True
        handle.Open()
        self._handler = handle
    def _initialize_openhardwaremonitor(self, dll_dir):
        # Create and import Open Hardware Monitor .dll
        clr.AddReference(dll_dir)
        from OpenHardwareMonitor import Hardware

        handle = Hardware.Computer()
        handle.MainboardEnabled = True
        handle.CPUEnabled = True
        handle.RAMEnabled = True
        handle.GPUEnabled = True
        handle.HDDEnabled = True
        handle.Open()
        return handle
Ejemplo n.º 15
0
def init_open_hwd_mon():
    file = 'OpenHardwareMonitorLib'
    try:
        clr.AddReference(file)
        from OpenHardwareMonitor import Hardware
        handle = Hardware.Computer()
        handle.CPUEnabled = True
        handle.Open()
        return handle
    except:
        print("WARNING: %s.lib NOT FOUND (Temps will be disabled)" % file)
        time.sleep(1)
        return None
Ejemplo n.º 16
0
 def initialize_openhardwaremonitor(self):
     file = 'OpenHardwareMonitorLib'
     clr.AddReference(file)
 
     from OpenHardwareMonitor import Hardware
 
     handle = Hardware.Computer()
     handle.MainboardEnabled = True
     handle.CPUEnabled = True
     handle.RAMEnabled = True
     handle.GPUEnabled = True
     handle.HDDEnabled = True
     handle.Open()
     return handle
Ejemplo n.º 17
0
 def __init__(self):
     if os.name == 'nt':
         file = 'CPUThermometerLib'
         clr.AddReference(file)
         from OpenHardwareMonitor import Hardware
         handle = Hardware.Computer()
         handle.CPUEnabled = True
         handle.Open()
         self.cpu = handle.Hardware[0]
         self.os = 1
         logging.debug("Win")
     else:
         import psutil
         self.os = 0
Ejemplo n.º 18
0
def initialize_openhardwaremonitor():
    file = os.getcwd() + '\\dll\\OpenHardwareMonitorLib.dll'
    clr.AddReference(file)

    from OpenHardwareMonitor import Hardware

    handle = Hardware.Computer()
    handle.MainboardEnabled = True
    handle.CPUEnabled = True
    handle.RAMEnabled = True
    handle.GPUEnabled = True
    handle.HDDEnabled = True
    handle.Open()
    return handle
Ejemplo n.º 19
0
def initialize_openhardwaremonitor():
    file = r'C:\Program Files\OpenHardwareMonitor\OpenHardwareMonitorLib.dll'
    clr.AddReference(file)

    from OpenHardwareMonitor import Hardware

    handle = Hardware.Computer()
    handle.MainboardEnabled = True
    handle.CPUEnabled = True
    handle.RAMEnabled = True
    handle.GPUEnabled = True
    handle.HDDEnabled = True
    handle.Open()
    return handle
Ejemplo n.º 20
0
def initialize_openhardwaremonitor():
    file = 'D:\git\prototype\Temp_UI\OpenHardwareMonitorLib.dll'
    clr.AddReference(file)

    from OpenHardwareMonitor import Hardware

    handle = Hardware.Computer()
    handle.MainboardEnabled = True
    handle.CPUEnabled = True
    handle.RAMEnabled = True
    handle.GPUEnabled = True
    handle.HDDEnabled = True
    handle.Open()
    return handle
Ejemplo n.º 21
0
def initialize_openhardwaremonitor():
    file = 'E:\Projects\hw-monitor-server\OpenHardwareMonitorLib'
    clr.AddReference(file)

    from OpenHardwareMonitor import Hardware

    handle = Hardware.Computer()
    # handle.MainboardEnabled = True
    handle.CPUEnabled = True
    # handle.RAMEnabled = True
    # handle.GPUEnabled = True
    # handle.HDDEnabled = True
    handle.Open()
    return handle
Ejemplo n.º 22
0
def initialize_openhardwaremonitor():
    DIR = os.path.abspath(os.path.dirname(__file__))
    dll_file_name = DIR + R'\OpenHardwareMonitorLib.dll'
    clr.AddReference(dll_file_name)

    from OpenHardwareMonitor import Hardware
    handle = Hardware.Computer()
    handle.MainboardEnabled = True
    handle.CPUEnabled = True
    handle.RAMEnabled = True
    handle.GPUEnabled = True
    handle.HDDEnabled = True
    handle.Open()
    return handle
Ejemplo n.º 23
0
# List for hardware types and sensor types that our DLL can open
OHM_hwtypes = [
    "Mainboard", "SuperIO", "CPU", "RAM", "GpuNvidia", "GpuAti", "TBalancer",
    "Heatmaster", "SSD"
]
OHM_sensortypes = [
    "Voltage", "Clock", "Temperature", "Load", "Fan", "Flow", "Control",
    "Level", "Factor", "Power", "Data", "SmallData"
]

clr.AddReference(
    os.path.join(os.path.dirname(os.path.abspath(__file__)),
                 "OpenHardwareMonitorLib.dll"))
from OpenHardwareMonitor import Hardware
hw = Hardware.Computer()
hw.MainboardEnabled, hw.CPUEnabled, hw.RAMEnabled, hw.GPUEnabled, hw.HDDEnabled = True, True, True, True, True
hw.Open()


def fetch_data():
    out = []
    for i in hw.Hardware:
        i.Update()
        for sensor in i.Sensors:
            sensor_output = parse_sensor(sensor)
            if sensor_output is not None:
                out.append(sensor_output)
        for j in i.SubHardware:
            j.Update()
            for subsensor in j.Sensors:
Ejemplo n.º 24
0
import time
import threading

import psutil
import pythonping
import GPUtil
import termcolor
from components_info import COMPONENTS_INFO
from OpenHardwareMonitor import Hardware

import user_actions
import config

COMPUTER = Hardware.Computer()
COMPUTER.CPUEnabled = True
COMPUTER.GPUEnabled = True
COMPUTER.Open()


class GetDisplayData:
    def __init__(self):
        threading.Thread(target=GetGPUInfo, daemon=True).start()
        threading.Thread(target=GetCPUInfo, daemon=True).start()
        threading.Thread(target=GetRAMInfo, daemon=True).start()
        threading.Thread(target=GetGPUInfo, daemon=True).start()
        threading.Thread(target=GetFPSInfo, daemon=True).start()
        threading.Thread(target=GetInternetInfo, daemon=True).start()

        time.sleep(0.2)
        user_actions.get_user_input()
Ejemplo n.º 25
0
    'Level', 'Factor', 'Power', 'Data', 'SmallData', 'Throughput'
]
hardware_types = [
    'Mainboard', 'SuperIO', 'cpu', 'ram', 'gpu', 'gpu', 'Heatmaster', 'hdd',
    'hdd'
]
sub_prop = {
    'cpu': ['temperature', 'power'],
    'gpu': ['temperature', 'power'],
    'ram': [],
    'hdd': ['temperature'],
}

from OpenHardwareMonitor import Hardware

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


def get_hardware_info(process=False):
    lis = []
    for i in handle.Hardware:
        i.Update()
        for sub in i.SubHardware:
            print(sub)
        if i.Sensors:
            obj = {