-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code refactoring and cleanup. Organized imports. Added temperature-re…
…ader classes. Fixed bug,
- Loading branch information
Showing
10 changed files
with
107 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,3 +70,6 @@ def _monitoring_action(self): | |
# endregion | ||
|
||
pass | ||
|
||
|
||
__all__ = ['AbsMonitor'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,3 +140,6 @@ def _monitoring_action(self): | |
# endregion | ||
|
||
pass | ||
|
||
|
||
__all__ = ['NetworkInterface'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from functools import partial | ||
from os import path | ||
|
||
|
||
class LinuxCpuTemperatureReader(): | ||
files = [ | ||
'/sys/devices/LNXSYSTM:00/LNXTHERM:00/LNXTHERM:01/thermal_zone/temp', | ||
'/sys/bus/acpi/devices/LNXTHERM:00/thermal_zone/temp', | ||
'/proc/acpi/thermal_zone/THM0/temperature', | ||
'/proc/acpi/thermal_zone/THRM/temperature', | ||
'/proc/acpi/thermal_zone/THR1/temperature' | ||
] | ||
|
||
@classmethod | ||
def get_reader(cls): | ||
readers = { | ||
cls.files[0]: cls.reader1, | ||
cls.files[1]: cls.reader1, | ||
cls.files[2]: cls.reader2, | ||
cls.files[3]: cls.reader2, | ||
cls.files[4]: cls.reader2 | ||
} | ||
for file in cls.files: | ||
if path.exists(file): | ||
reader = readers.get(file) | ||
if reader: | ||
return reader(file) | ||
|
||
@classmethod | ||
def reader1(cls, file): | ||
def reader(file): | ||
temperature = open(file).read().strip() | ||
temperature = int(temperature) // 1000 | ||
return temperature | ||
return partial(reader, file) | ||
|
||
@classmethod | ||
def reader2(cls, file): | ||
def reader(file): | ||
temperature = open(file).read().strip() | ||
temperature = temperature.lstrip('temperature :').rstrip(' C') | ||
return int(temperature) | ||
return partial(reader, file) | ||
|
||
|
||
class WindowsCpuTemperatureReader(): | ||
|
||
@classmethod | ||
def get_reader(): | ||
import wmi | ||
import pythoncom | ||
|
||
def temperature_reader(): | ||
pythoncom.CoInitialize() | ||
w = wmi.WMI(namespace='root\\wmi') | ||
temperature = w.MSAcpi_ThermalZoneTemperature()[0] | ||
temperature = int(temperature.CurrentTemperature / 10.0 - 273.15) | ||
return temperature | ||
return temperature_reader | ||
|
||
|
||
__all__ = ['LinuxCpuTemperatureReader', 'WindowsCpuTemperatureReader'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,17 +45,17 @@ def main(): | |
# Describe installer | ||
settings = { | ||
'name': 'pyspectator', | ||
'version': '1.0.8', | ||
'version': '1.1.0', | ||
'author': 'Maxim Grischuk, Vova Sirenko', | ||
'author_email': '[email protected]', | ||
'maintainer': 'Maxim Grischuk', | ||
'maintainer_email': '[email protected]', | ||
'packages': ['pyspectator'], | ||
'url': 'https://github.com/opium999/pyspectator', | ||
'download_url': 'https://github.com/opium999/pyspectator/releases', | ||
'url': 'https://github.com/uzumaxy/pyspectator', | ||
'download_url': 'https://github.com/uzumaxy/pyspectator/releases', | ||
'license': 'BSD', | ||
'description': 'pyspectator is a cross-platform tool for retrieving ' | ||
'full information about computer.', | ||
'description': 'pyspectator is a Python cross-platform tool for ' | ||
'monitoring OS resources.', | ||
'long_description': open('README.rst').read(), | ||
'install_requires': requires, | ||
'keywords': [ | ||
|