pyhw 0.6.7__py3-none-any.whl → 0.7.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. pyhw/__main__.py +2 -2
  2. pyhw/backend/cpu/bsd.py +12 -0
  3. pyhw/backend/cpu/cpuBase.py +3 -0
  4. pyhw/backend/gpu/bsd.py +7 -0
  5. pyhw/backend/gpu/gpuBase.py +3 -0
  6. pyhw/backend/host/bsd.py +13 -0
  7. pyhw/backend/host/hostBase.py +3 -0
  8. pyhw/backend/host/linux.py +21 -21
  9. pyhw/backend/kernel/kernelBase.py +1 -3
  10. pyhw/backend/memory/bsd.py +11 -0
  11. pyhw/backend/memory/linux.py +8 -8
  12. pyhw/backend/memory/memoryBase.py +3 -0
  13. pyhw/backend/nic/bsd.py +7 -0
  14. pyhw/backend/nic/linux.py +12 -12
  15. pyhw/backend/nic/nicBase.py +5 -0
  16. pyhw/backend/npu/bsd.py +6 -0
  17. pyhw/backend/npu/linux.py +14 -18
  18. pyhw/backend/npu/npuBase.py +3 -0
  19. pyhw/backend/os/bsd.py +7 -0
  20. pyhw/backend/os/linux.py +19 -19
  21. pyhw/backend/os/osBase.py +3 -0
  22. pyhw/backend/shell/shellBase.py +1 -1
  23. pyhw/backend/shell/unix.py +0 -1
  24. pyhw/backend/title/titleBase.py +1 -1
  25. pyhw/backend/uptime/bsd.py +7 -0
  26. pyhw/backend/uptime/macos.py +12 -12
  27. pyhw/backend/uptime/uptimeBase.py +3 -0
  28. pyhw/frontend/color/colorConfig.py +10 -0
  29. pyhw/frontend/frontendBase.py +8 -1
  30. pyhw/frontend/logo/ascii/freebsd.pyhw +15 -0
  31. pyhw/pyhwUtil/pyhwUtil.py +18 -8
  32. {pyhw-0.6.7.dist-info → pyhw-0.7.0.dist-info}/METADATA +15 -7
  33. {pyhw-0.6.7.dist-info → pyhw-0.7.0.dist-info}/RECORD +37 -29
  34. {pyhw-0.6.7.dist-info → pyhw-0.7.0.dist-info}/WHEEL +1 -1
  35. pyhw/macos.py +0 -146
  36. {pyhw-0.6.7.dist-info → pyhw-0.7.0.dist-info}/LICENSE +0 -0
  37. {pyhw-0.6.7.dist-info → pyhw-0.7.0.dist-info}/entry_points.txt +0 -0
  38. {pyhw-0.6.7.dist-info → pyhw-0.7.0.dist-info}/top_level.txt +0 -0
pyhw/__main__.py CHANGED
@@ -17,8 +17,8 @@ from .pyhwUtil import getOS, selectOSLogo
17
17
 
18
18
  def main():
19
19
  current_os = getOS()
20
- if current_os != "linux" and current_os != "macos":
21
- print(f"Only Linux and macOS is supported for now. Current os: {current_os}")
20
+ if current_os not in ["linux", "macos", "freebsd"]:
21
+ print(f"Only Linux, macOS, and FreeBSD is supported for now. Current os: {current_os}")
22
22
  return
23
23
  data = Data()
24
24
  data.title = TitleDetect(os=current_os).getTitle().title
@@ -0,0 +1,12 @@
1
+ from .cpuInfo import CPUInfo
2
+ from ...pyhwUtil import sysctlGetString, sysctlGetInt, getArch
3
+
4
+
5
+ class CPUDetectBSD:
6
+ def __init__(self):
7
+ self.__cpuInfo = CPUInfo()
8
+
9
+ def getCPUInfo(self):
10
+ self.__cpuInfo.cpu = sysctlGetString("hw.model")
11
+ return self.__cpuInfo
12
+
@@ -1,5 +1,6 @@
1
1
  from .linux import CPUDetectLinux
2
2
  from .macos import CPUDetectMacOS
3
+ from .bsd import CPUDetectBSD
3
4
  from ...pyhwException import OSUnsupportedException
4
5
 
5
6
 
@@ -12,5 +13,7 @@ class CPUDetect:
12
13
  return CPUDetectLinux().getCPUInfo()
13
14
  elif self.OS == "macos":
14
15
  return CPUDetectMacOS().getCPUInfo()
16
+ elif self.OS == "freebsd":
17
+ return CPUDetectBSD().getCPUInfo()
15
18
  else:
16
19
  raise OSUnsupportedException("Unsupported operating system")
@@ -0,0 +1,7 @@
1
+ from .linux import GPUDetectLinux
2
+
3
+
4
+ class GPUDetectBSD(GPUDetectLinux):
5
+ def __init__(self):
6
+ super().__init__()
7
+
@@ -1,5 +1,6 @@
1
1
  from .linux import GPUDetectLinux
2
2
  from .macos import GPUDetectMacOS
3
+ from .bsd import GPUDetectBSD
3
4
 
4
5
 
5
6
  class GPUDetect:
@@ -11,5 +12,7 @@ class GPUDetect:
11
12
  return GPUDetectLinux().getGPUInfo()
12
13
  elif self.OS == "macos":
13
14
  return GPUDetectMacOS().getGPUInfo()
15
+ elif self.OS == "freebsd":
16
+ return GPUDetectBSD().getGPUInfo()
14
17
  else:
15
18
  raise NotImplementedError("Unsupported operating system")
@@ -0,0 +1,13 @@
1
+ from .linux import HostDetectLinux
2
+
3
+
4
+ class HostDetectBSD(HostDetectLinux):
5
+ def __init__(self):
6
+ HostDetectLinux.__init__(self)
7
+
8
+ def getHostInfo(self):
9
+ self._hostInfo.name = f"General {self._arch} FreeBSD Host"
10
+ self._hostInfo.version = ""
11
+ self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
12
+ return self._hostInfo
13
+
@@ -1,6 +1,7 @@
1
1
  from .linux import HostDetectLinux
2
2
  from .macos import HostDetectMacOS
3
3
  from .windows import HostDetectWindows
4
+ from .bsd import HostDetectBSD
4
5
  from ...pyhwException import OSUnsupportedException
5
6
 
6
7
 
@@ -13,6 +14,8 @@ class HostDetect:
13
14
  return HostDetectLinux().getHostInfo()
14
15
  elif self.OS == "macos":
15
16
  return HostDetectMacOS().getHostInfo()
17
+ elif self.OS == "freebsd":
18
+ return HostDetectBSD().getHostInfo()
16
19
  elif self.OS == "windows":
17
20
  pass
18
21
  else:
@@ -8,53 +8,53 @@ import os
8
8
 
9
9
  class HostDetectLinux:
10
10
  def __init__(self):
11
- self.__hostInfo = HostInfo()
12
- self.__arch = getArch()
13
- self.__docker = getDocker()
11
+ self._hostInfo = HostInfo()
12
+ self._arch = getArch()
13
+ self._docker = getDocker()
14
14
 
15
15
  def getHostInfo(self):
16
- self.__getModel()
17
- return self.__hostInfo
16
+ self._getModel()
17
+ return self._hostInfo
18
18
 
19
- def __getModel(self):
20
- if self.__docker:
21
- self.__hostInfo.name = f"General {self.__arch} Docker Host"
22
- self.__hostInfo.version = ""
23
- self.__hostInfo.model = self.__hostInfo.name + " " + self.__hostInfo.version
19
+ def _getModel(self):
20
+ if self._docker:
21
+ self._hostInfo.name = f"General {self._arch} Docker Host"
22
+ self._hostInfo.version = ""
23
+ self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
24
24
  else:
25
- if self.__arch in ["x86_64", "x86"]:
25
+ if self._arch in ["x86_64", "x86"]:
26
26
  try:
27
27
  with open("/sys/devices/virtual/dmi/id/product_name", "r") as f:
28
28
  product_name = f.read().strip()
29
29
  if product_name.startswith("To be filled by O.E.M."):
30
- self.__hostInfo.name = f"General {self.__arch} Host"
30
+ self._hostInfo.name = f"General {self._arch} Host"
31
31
  else:
32
- self.__hostInfo.name = product_name
32
+ self._hostInfo.name = product_name
33
33
  with open("/sys/devices/virtual/dmi/id/product_version", "r") as f:
34
34
  version = f.read().strip()
35
35
  if version.startswith("To be filled by O.E.M."):
36
- self.__hostInfo.version = ""
36
+ self._hostInfo.version = ""
37
37
  else:
38
- self.__hostInfo.version = version
39
- self.__hostInfo.model = self.__hostInfo.name + " " + self.__hostInfo.version
38
+ self._hostInfo.version = version
39
+ self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
40
40
  except FileNotFoundError:
41
41
  pass
42
- elif self.__arch in ["aarch64", "arm32"]:
42
+ elif self._arch in ["aarch64", "arm32"]:
43
43
  # try to find dmi folder since some arm based desktops and servers may have same structure as x86_64 machines.
44
44
  if os.path.exists("/sys/devices/virtual/dmi/id"):
45
45
  try:
46
46
  with open("/sys/devices/virtual/dmi/id/product_name", "r") as f:
47
- self.__hostInfo.name = f.read().strip()
47
+ self._hostInfo.name = f.read().strip()
48
48
  with open("/sys/devices/virtual/dmi/id/product_version", "r") as f:
49
- self.__hostInfo.version = f.read().strip()
50
- self.__hostInfo.model = self.__hostInfo.name + " " + self.__hostInfo.version
49
+ self._hostInfo.version = f.read().strip()
50
+ self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
51
51
  except FileNotFoundError:
52
52
  pass
53
53
  else:
54
54
  # some single board computers may not have dmi folder, try to find model name in device tree.
55
55
  try:
56
56
  with open("/sys/firmware/devicetree/base/model", "r") as f:
57
- self.__hostInfo.model = f.read().strip()
57
+ self._hostInfo.model = f.read().strip()
58
58
  except FileNotFoundError:
59
59
  pass
60
60
 
@@ -7,9 +7,7 @@ class KernelDetect:
7
7
  self.OS = os
8
8
 
9
9
  def getKernelInfo(self):
10
- if self.OS == "linux":
11
- return KernelDetectUnix().getKernelInfo()
12
- elif self.OS == "macos":
10
+ if self.OS in ["linux", "macos", "freebsd"]:
13
11
  return KernelDetectUnix().getKernelInfo()
14
12
  elif self.OS == "windows":
15
13
  raise OSUnsupportedException("Unsupported operating system")
@@ -0,0 +1,11 @@
1
+ from .linux import MemoryDetectLinux
2
+
3
+
4
+ class MemoryDetectBSD(MemoryDetectLinux):
5
+ def __init__(self):
6
+ MemoryDetectLinux.__init__(self)
7
+
8
+ def getMemoryInfo(self):
9
+ self._memoryInfo.memory = f"Pass"
10
+ return self._memoryInfo
11
+
@@ -3,22 +3,22 @@ from .memoryInfo import MemoryInfo
3
3
 
4
4
  class MemoryDetectLinux:
5
5
  def __init__(self):
6
- self.__memoryInfo = MemoryInfo()
6
+ self._memoryInfo = MemoryInfo()
7
7
 
8
8
  def getMemoryInfo(self):
9
- self.__getMemory()
10
- self.__memoryInfo.memory = f"{self.__memoryInfo.used} MiB / {self.__memoryInfo.total} MiB"
11
- return self.__memoryInfo
9
+ self._getMemory()
10
+ self._memoryInfo.memory = f"{self._memoryInfo.used} MiB / {self._memoryInfo.total} MiB"
11
+ return self._memoryInfo
12
12
 
13
- def __getMemory(self):
13
+ def _getMemory(self):
14
14
  try:
15
15
  with open("/proc/meminfo", "r") as file:
16
16
  for line in file:
17
17
  if line.startswith("MemTotal:"):
18
- self.__memoryInfo.total = round(float(line.split(":")[1].strip()[:-3]) / 1024, 2)
18
+ self._memoryInfo.total = round(float(line.split(":")[1].strip()[:-3]) / 1024, 2)
19
19
  elif line.startswith("MemAvailable:"):
20
- self.__memoryInfo.available = round(float(line.split(":")[1].strip()[:-3]) / 1024, 2)
21
- self.__memoryInfo.used = round(self.__memoryInfo.total - self.__memoryInfo.available, 2)
20
+ self._memoryInfo.available = round(float(line.split(":")[1].strip()[:-3]) / 1024, 2)
21
+ self._memoryInfo.used = round(self._memoryInfo.total - self._memoryInfo.available, 2)
22
22
  except FileNotFoundError:
23
23
  pass
24
24
 
@@ -1,5 +1,6 @@
1
1
  from .linux import MemoryDetectLinux
2
2
  from .macos import MemoryDetectMacOS
3
+ from .bsd import MemoryDetectBSD
3
4
 
4
5
 
5
6
  class MemoryDetect:
@@ -11,5 +12,7 @@ class MemoryDetect:
11
12
  return MemoryDetectLinux().getMemoryInfo()
12
13
  elif self.OS == "macos":
13
14
  return MemoryDetectMacOS().getMemoryInfo()
15
+ elif self.OS == "freebsd":
16
+ return MemoryDetectBSD().getMemoryInfo()
14
17
  else:
15
18
  raise NotImplementedError("Unsupported operating system")
@@ -0,0 +1,7 @@
1
+ from .linux import NICDetectLinux
2
+
3
+
4
+ class NICDetectBSD(NICDetectLinux):
5
+ def __init__(self):
6
+ NICDetectLinux.__init__(self)
7
+
pyhw/backend/nic/linux.py CHANGED
@@ -7,14 +7,14 @@ import pypci
7
7
 
8
8
  class NICDetectLinux:
9
9
  def __init__(self):
10
- self.__nicInfo = NICInfo()
10
+ self._nicInfo = NICInfo()
11
11
 
12
12
  def getNICInfo(self):
13
- self.__getNICInfo()
14
- self.__sortNICList()
15
- return self.__nicInfo
13
+ self._getNICInfo()
14
+ self._sortNICList()
15
+ return self._nicInfo
16
16
 
17
- def __getNICInfo(self):
17
+ def _getNICInfo(self):
18
18
  nic_devices = pypci.PCI().FindAllNIC()
19
19
  if len(nic_devices) == 0:
20
20
  self.__handleNonePciDevices()
@@ -24,18 +24,18 @@ class NICDetectLinux:
24
24
  device_name = f"{device.vendor_name} {device.device_name} ({device.subsystem_device_name})"
25
25
  else:
26
26
  device_name = f"{device.vendor_name} {device.device_name}"
27
- self.__nicInfo.nics.append(self.__nicNameClean(device_name))
28
- self.__nicInfo.number += 1
27
+ self._nicInfo.nics.append(self._nicNameClean(device_name))
28
+ self._nicInfo.number += 1
29
29
 
30
30
  def __handleNonePciDevices(self):
31
31
  # placeholder for a more advanced method.
32
- self.__nicInfo.nics.append("Not found")
33
- self.__nicInfo.number = 1
32
+ self._nicInfo.nics.append("Not found")
33
+ self._nicInfo.number = 1
34
34
 
35
35
  @staticmethod
36
- def __nicNameClean(nic_name: str):
36
+ def _nicNameClean(nic_name: str):
37
37
  nic_name_clean = nic_name.replace("Corporation ", "")
38
38
  return nic_name_clean
39
39
 
40
- def __sortNICList(self):
41
- return self.__nicInfo.nics.sort()
40
+ def _sortNICList(self):
41
+ return self._nicInfo.nics.sort()
@@ -1,5 +1,6 @@
1
1
  from .linux import NICDetectLinux
2
2
  from .macos import NICDetectMacOS
3
+ from .bsd import NICDetectBSD
3
4
 
4
5
 
5
6
  class NICDetect:
@@ -18,3 +19,7 @@ class NICDetect:
18
19
  return NICDetectLinux().getNICInfo()
19
20
  elif self.OS == "macos":
20
21
  return NICDetectMacOS().getNICInfo()
22
+ elif self.OS == "freebsd":
23
+ return NICDetectBSD().getNICInfo()
24
+ else:
25
+ raise NotImplementedError("Unsupported operating system")
@@ -0,0 +1,6 @@
1
+ from .linux import NPUDetectLinux
2
+
3
+
4
+ class NPUDetectBSD(NPUDetectLinux):
5
+ def __init__(self):
6
+ NPUDetectLinux.__init__(self)
pyhw/backend/npu/linux.py CHANGED
@@ -1,42 +1,38 @@
1
- import subprocess
2
1
  from .npuInfo import NPUInfo
3
- from ..cpu import CPUDetect
4
- from ...pyhwUtil import getArch
5
2
  import pypci
6
3
 
7
4
 
8
5
  class NPUDetectLinux:
9
6
  def __init__(self):
10
- self.__npuInfo = NPUInfo()
7
+ self._npuInfo = NPUInfo()
11
8
 
12
9
  def getNPUInfo(self):
13
- self.__getNPUInfo()
14
- self.__sortNPUList()
15
- return self.__npuInfo
10
+ self._getNPUInfo()
11
+ self._sortNPUList()
12
+ return self._npuInfo
16
13
 
17
- def __getNPUInfo(self):
14
+ def _getNPUInfo(self):
18
15
  npu_devices = pypci.PCI().FindAllNPU()
19
16
  if len(npu_devices) == 0:
20
- self.__handleNonePciDevices()
17
+ self._handleNonePciDevices()
21
18
  else:
22
19
  for device in npu_devices:
23
20
  if device.subsystem_device_name != "":
24
21
  device_name = f"{device.vendor_name} {device.device_name} ({device.subsystem_device_name})"
25
22
  else:
26
23
  device_name = f"{device.vendor_name} {device.device_name}"
27
- self.__npuInfo.npus.append(self.__npuNameClean(device_name))
28
- self.__npuInfo.number += 1
24
+ self._npuInfo.npus.append(self._npuNameClean(device_name))
25
+ self._npuInfo.number += 1
29
26
 
30
- def __handleNonePciDevices(self):
27
+ def _handleNonePciDevices(self):
31
28
  # Place Holder for unknown NPU
32
- self.__npuInfo.number = 1
33
- self.__npuInfo.npus.append("Not found")
29
+ self._npuInfo.number = 1
30
+ self._npuInfo.npus.append("Not found")
34
31
 
35
32
  @staticmethod
36
- def __npuNameClean(npu_name: str):
33
+ def _npuNameClean(npu_name: str):
37
34
  npu_name_clean = npu_name.replace("Corporation ", "")
38
35
  return npu_name_clean
39
36
 
40
- def __sortNPUList(self):
41
- self.__npuInfo.npus.sort()
42
-
37
+ def _sortNPUList(self):
38
+ self._npuInfo.npus.sort()
@@ -1,5 +1,6 @@
1
1
  from .linux import NPUDetectLinux
2
2
  from .macos import NPUDetectMacOS
3
+ from .bsd import NPUDetectBSD
3
4
 
4
5
 
5
6
  class NPUDetect:
@@ -11,6 +12,8 @@ class NPUDetect:
11
12
  return NPUDetectLinux().getNPUInfo()
12
13
  elif self.OS == "macos":
13
14
  return NPUDetectMacOS().getNPUInfo()
15
+ elif self.OS == "freebsd":
16
+ return NPUDetectBSD().getNPUInfo()
14
17
  else:
15
18
  raise NotImplementedError("Unsupported operating system")
16
19
 
pyhw/backend/os/bsd.py ADDED
@@ -0,0 +1,7 @@
1
+ from .linux import OSDetectLinux
2
+
3
+
4
+ class OSDetectBSD(OSDetectLinux):
5
+ def __init__(self):
6
+ OSDetectLinux.__init__(self)
7
+
pyhw/backend/os/linux.py CHANGED
@@ -6,47 +6,47 @@ from .osInfo import OSInfo
6
6
 
7
7
  class OSDetectLinux:
8
8
  def __init__(self):
9
- self.__osInfo = OSInfo()
9
+ self._osInfo = OSInfo()
10
10
 
11
11
  def getOSInfo(self):
12
12
  """
13
13
  Detects the os distribution and its version.
14
14
  :return: dataclass OSInfoLinux, direct attrs: prettyName
15
15
  """
16
- self.__getOSInfo()
17
- self.__handleArmbian()
18
- return self.__osInfo
16
+ self._getOSInfo()
17
+ self._handleArmbian()
18
+ return self._osInfo
19
19
 
20
- def __getOSInfo(self):
20
+ def _getOSInfo(self):
21
21
  try:
22
22
  with open("/etc/os-release", "r") as f:
23
23
  for line in f:
24
24
  key, value = line.strip().split("=")
25
25
  if key == "PRETTY_NAME":
26
- self.__osInfo.prettyName = value.strip('"')
26
+ self._osInfo.prettyName = value.strip('"')
27
27
  elif key == "NAME":
28
- self.__osInfo.name = value.strip('"')
28
+ self._osInfo.name = value.strip('"')
29
29
  elif key == "ID":
30
- self.__osInfo.id = value.strip('"')
30
+ self._osInfo.id = value.strip('"')
31
31
  elif key == "ID_LIKE":
32
- self.__osInfo.idLike = value.strip('"')
32
+ self._osInfo.idLike = value.strip('"')
33
33
  elif key == "VARIANT":
34
- self.__osInfo.variant = value.strip('"')
34
+ self._osInfo.variant = value.strip('"')
35
35
  elif key == "VARIANT_ID":
36
- self.__osInfo.variantID = value.strip('"')
36
+ self._osInfo.variantID = value.strip('"')
37
37
  elif key == "VERSION":
38
- self.__osInfo.version = value.strip('"')
38
+ self._osInfo.version = value.strip('"')
39
39
  elif key == "VERSION_ID":
40
- self.__osInfo.versionID = value.strip('"')
40
+ self._osInfo.versionID = value.strip('"')
41
41
  elif key == "VERSION_CODENAME":
42
- self.__osInfo.versionCodename = value.strip('"')
42
+ self._osInfo.versionCodename = value.strip('"')
43
43
  elif key == "CODE_NAME":
44
- self.__osInfo.codeName = value.strip('"')
44
+ self._osInfo.codeName = value.strip('"')
45
45
  elif key == "BUILD_ID":
46
- self.__osInfo.buildID = value.strip('"')
46
+ self._osInfo.buildID = value.strip('"')
47
47
  except Exception:
48
48
  pass
49
49
 
50
- def __handleArmbian(self):
51
- if "Armbian" in self.__osInfo.prettyName or "armbian" in self.__osInfo.prettyName:
52
- self.__osInfo.id = "armbian"
50
+ def _handleArmbian(self):
51
+ if "Armbian" in self._osInfo.prettyName or "armbian" in self._osInfo.prettyName:
52
+ self._osInfo.id = "armbian"
pyhw/backend/os/osBase.py CHANGED
@@ -1,5 +1,6 @@
1
1
  from .linux import OSDetectLinux
2
2
  from .macos import OSDetectMacOS
3
+ from .bsd import OSDetectBSD
3
4
  from ...pyhwException import OSUnsupportedException
4
5
 
5
6
 
@@ -12,5 +13,7 @@ class OSDetect:
12
13
  return OSDetectLinux().getOSInfo()
13
14
  elif self.__OS == "macos":
14
15
  return OSDetectMacOS().getOSInfo()
16
+ elif self.__OS == "freebsd":
17
+ return OSDetectBSD().getOSInfo()
15
18
  else:
16
19
  raise OSUnsupportedException("Unsupported operating system")
@@ -7,7 +7,7 @@ class ShellDetect:
7
7
  self.OS = os
8
8
 
9
9
  def getShellInfo(self):
10
- if self.OS == "linux" or self.OS == "macos":
10
+ if self.OS in ["linux", "macos", "freebsd"]:
11
11
  return ShellDetectUnix().getShellInfo()
12
12
  else:
13
13
  raise OSUnsupportedException("Unsupported operating system")
@@ -26,7 +26,6 @@ class ShellDetectUnix:
26
26
  self.__getShell()
27
27
  self.__getVersion()
28
28
  self.__shellInfo.info = self.__shellInfo.shell + " " + self.__shellInfo.version
29
- print(self.__shellInfo.info)
30
29
  return self.__shellInfo
31
30
 
32
31
  def __getShell(self):
@@ -8,7 +8,7 @@ class TitleDetect:
8
8
  self.OS = os
9
9
 
10
10
  def getTitle(self):
11
- if self.OS == "linux" or self.OS == "macos":
11
+ if self.OS in ["linux", "macos", "freebsd"]:
12
12
  return TitleDetectUnix().getTitle()
13
13
  elif self.OS == "windows":
14
14
  return TitleDetectWindows().getTitle()
@@ -0,0 +1,7 @@
1
+ from .macos import UptimeDetectMacOS
2
+
3
+
4
+ class UptimeDetectBSD(UptimeDetectMacOS):
5
+ def __init__(self):
6
+ UptimeDetectMacOS.__init__(self)
7
+
@@ -6,13 +6,13 @@ import subprocess
6
6
 
7
7
  class UptimeDetectMacOS:
8
8
  def __init__(self):
9
- self.__uptimeInfo = UptimeInfo()
10
- self.__boot_time = 0
11
- self.__now = 0
9
+ self._uptimeInfo = UptimeInfo()
10
+ self._boot_time = 0
11
+ self._now = 0
12
12
 
13
13
  def getUptimeInfo(self):
14
- self.__getUptime()
15
- uptime_seconds = self.__now - self.__boot_time
14
+ self._getUptime()
15
+ uptime_seconds = self._now - self._boot_time
16
16
  hours, remainder = divmod(uptime_seconds, 3600)
17
17
  minutes, seconds = divmod(remainder, 60)
18
18
  days, hours = divmod(hours, 24)
@@ -22,19 +22,19 @@ class UptimeDetectMacOS:
22
22
  seconds = int(seconds)
23
23
  if days == 0:
24
24
  if hours == 0:
25
- self.__uptimeInfo.uptime = f"{minutes} min {seconds} sec"
25
+ self._uptimeInfo.uptime = f"{minutes} min {seconds} sec"
26
26
  else:
27
- self.__uptimeInfo.uptime = f"{hours} hours {minutes} min {seconds} sec"
27
+ self._uptimeInfo.uptime = f"{hours} hours {minutes} min {seconds} sec"
28
28
  else:
29
- self.__uptimeInfo.uptime = f"{days} days {hours} hours {minutes} min {seconds} sec"
30
- return self.__uptimeInfo
29
+ self._uptimeInfo.uptime = f"{days} days {hours} hours {minutes} min {seconds} sec"
30
+ return self._uptimeInfo
31
31
 
32
- def __getUptime(self):
32
+ def _getUptime(self):
33
33
  result = sysctlGetString("kern.boottime")
34
34
  match = re.search(r'sec = (\d+),', result)
35
35
  if match:
36
- self.__boot_time = int(match.group(1))
36
+ self._boot_time = int(match.group(1))
37
37
  else:
38
38
  return
39
- self.__now = int(subprocess.check_output(["date", "+%s"]).decode().strip())
39
+ self._now = int(subprocess.check_output(["date", "+%s"]).decode().strip())
40
40
 
@@ -1,5 +1,6 @@
1
1
  from .linux import UptimeDetectLinux
2
2
  from .macos import UptimeDetectMacOS
3
+ from .bsd import UptimeDetectBSD
3
4
  from ...pyhwException import OSUnsupportedException
4
5
 
5
6
 
@@ -19,5 +20,7 @@ class UptimeDetect:
19
20
  return UptimeDetectLinux().getUptimeInfo()
20
21
  elif self.OS == "macos":
21
22
  return UptimeDetectMacOS().getUptimeInfo()
23
+ elif self.OS == "freebsd":
24
+ return UptimeDetectBSD().getUptimeInfo()
22
25
  else:
23
26
  raise OSUnsupportedException("Unsupported operating system")
@@ -31,6 +31,8 @@ class ColorConfigSet:
31
31
  return ColorConfigSetA.arch
32
32
  elif self.__os_name == "centos":
33
33
  return ColorConfigSetC.centos
34
+ elif self.__os_name == "freebsd":
35
+ return ColorConfigSetF.freebsd
34
36
  else:
35
37
  return ColorConfigSetL.linux # default to Linux
36
38
 
@@ -107,6 +109,14 @@ class ColorConfigSetF:
107
109
  "colorKeys": ColorSet.COLOR_FG_BLUE,
108
110
  "colorTitle": ColorSet.COLOR_FG_BLUE
109
111
  }
112
+ freebsd = {
113
+ "colors": [
114
+ ColorSet.COLOR_FG_WHITE,
115
+ ColorSet.COLOR_FG_RED
116
+ ],
117
+ "colorKeys": ColorSet.COLOR_FG_RED,
118
+ "colorTitle": ColorSet.COLOR_FG_RED
119
+ }
110
120
 
111
121
 
112
122
  @dataclass
@@ -1,6 +1,7 @@
1
1
  from .logo import Logo
2
2
  from .color import ColorConfigSet, colorPrefix, colorSuffix, ColorSet
3
3
  from ..pyhwUtil import getOS
4
+ from ..pyhwException import BackendException
4
5
  import os
5
6
  import re
6
7
 
@@ -95,7 +96,13 @@ class Printer:
95
96
  self.__data_lines[0].split("@")[1] + colorSuffix())
96
97
  self.__processed_data_lines.append(colorSuffix() + self.__data_lines[1])
97
98
  for data_line in self.__data_lines[2:]:
98
- name, value = data_line.split(": ")
99
+ try:
100
+ spl = data_line.split(": ")
101
+ name = spl[0]
102
+ value = "".join(spl[1:])
103
+ except:
104
+ print(data_line)
105
+ raise BackendException("Invalid data format")
99
106
  self.__processed_data_lines.append(colorPrefix(ColorSet.COLOR_MODE_BOLD) + colorPrefix(keys_color) + name + ": " + colorSuffix() + value)
100
107
 
101
108
 
@@ -0,0 +1,15 @@
1
+ ``` $2`
2
+ $1` `.....---...$2....--.``` -/
3
+ $1+o .--` $2/y:` +.
4
+ $1yo`:. $2:o `+-
5
+ $1y/ $2-/` -o/
6
+ $1.- $2::/sy+:.
7
+ $1/ $2`-- /
8
+ $1`: $2:`
9
+ $1`: $2:`
10
+ $1/ $2/
11
+ $1.- $2-.
12
+ $1-- $2-.
13
+ $1`:` $2`:`
14
+ .-- `--.
15
+ .---.....----.
pyhw/pyhwUtil/pyhwUtil.py CHANGED
@@ -7,7 +7,7 @@ from dataclasses import dataclass
7
7
  def getOS():
8
8
  """
9
9
  Get the os type in lower case.
10
- :return: str, os type, value in [windows, linux, macos, unknown].
10
+ :return: str, os type, value in [windows, linux, macos, freebsd, unknown].
11
11
  """
12
12
  system = platform.system()
13
13
  if system == "Windows":
@@ -16,6 +16,8 @@ def getOS():
16
16
  return "linux"
17
17
  elif system == "Darwin":
18
18
  return "macos"
19
+ elif system == "FreeBSD":
20
+ return "freebsd"
19
21
  else:
20
22
  return "unknown"
21
23
 
@@ -54,8 +56,11 @@ class DataStringProcessor:
54
56
  @staticmethod
55
57
  def __getENV() -> int:
56
58
  if getOS() == "linux":
57
- _, columns_str = os.popen('stty size', 'r').read().split()
58
- columns = int(columns_str)
59
+ try:
60
+ _, columns_str = os.popen('stty size', 'r').read().split()
61
+ columns = int(columns_str)
62
+ except:
63
+ columns = 80 # default terminal size is 80 columns
59
64
  else:
60
65
  # macOS default terminal size is 80 columns
61
66
  columns = 80
@@ -168,8 +173,8 @@ def createDataStringOld(data: Data):
168
173
 
169
174
  @dataclass
170
175
  class SupportedOS:
171
- ColorConfig = ["armbian", "arch", "alpine", "centos", "debian", "fedora", "macOS", "raspbian", "ubuntu"]
172
- AsciiLogo = ["armbian", "arch", "alpine", "centos", "debian", "fedora", "macOS", "raspbian", "ubuntu"]
176
+ ColorConfig = ["armbian", "arch", "alpine", "centos", "debian", "fedora", "macOS", "raspbian", "ubuntu", "freebsd"]
177
+ AsciiLogo = ["armbian", "arch", "alpine", "centos", "debian", "fedora", "macOS", "raspbian", "ubuntu", "freebsd"]
173
178
 
174
179
 
175
180
  def selectOSLogo(os_id: str):
@@ -184,9 +189,14 @@ def selectOSLogo(os_id: str):
184
189
  pass
185
190
  else:
186
191
  return "linux"
187
- rows_str, columns_str = os.popen('stty size', 'r').read().split()
188
- rows = int(rows_str)
189
- columns = int(columns_str)
192
+ try:
193
+ rows_str, columns_str = os.popen('stty size', 'r').read().split()
194
+ rows = int(rows_str)
195
+ columns = int(columns_str)
196
+ except:
197
+ # Default terminal size is 24 rows and 80 columns
198
+ rows = 24
199
+ columns = 80
190
200
  if columns <= 80:
191
201
  if os_id in ["fedora", "ubuntu"]:
192
202
  return f"{os_id}_small"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyhw
3
- Version: 0.6.7
3
+ Version: 0.7.0
4
4
  Summary: PyHw, a neofetch-like command line tool for fetching system information but written mostly in python.
5
5
  Author-email: Xiao Ran <xiaoran.007@icloud.com>
6
6
  License: BSD-3-Clause
@@ -22,9 +22,10 @@ Requires-Dist: pypci-ng>=0.0.8
22
22
  ![Static Badge](https://img.shields.io/badge/macOS-11%2B-green
23
23
  )
24
24
  ![Static Badge](https://img.shields.io/badge/Linux-blue)
25
+ ![Static Badge](https://img.shields.io/badge/FreeBSD-red)
25
26
 
26
27
 
27
- PyHw, a neofetch-like command line tool for fetching system information but written mostly in Python. **Currently, this project is still in the initial stage, only part of the linux systems and macOS are supported.**
28
+ PyHw, a neofetch-like command line tool for fetching system information but written mostly in Python. **Currently, this project is still in the initial stage, only Linux, macOS, and FreeBSD are supported.**
28
29
 
29
30
  This project is a Python reimplementation of [neofetch](https://github.com/dylanaraps/neofetch) and references the [fastfetch](https://github.com/fastfetch-cli/fastfetch) project for logo style settings. Since this project is implemented in Python, it will be easier to maintain and extend than bash and c implementation. Also, this project only relies on the Python standard library, so you can run it on any device that has a Python environment (I hope so 🤔).
30
31
 
@@ -50,6 +51,8 @@ pip install pyhw --upgrade
50
51
  You can then use this tool directly from the command line with the following command, just like neofetch.
51
52
  ```shell
52
53
  pyhw
54
+ # or
55
+ python -m pyhw
53
56
  ```
54
57
  Please note that the command line entry for __pyhw__ is created by pip, and depending on the user, this entry may not in the __system PATH__. If you encounter this problem, pip will give you a prompt, follow the prompts to add entry to the __system PATH__.
55
58
 
@@ -66,7 +69,7 @@ pyhw
66
69
  ```
67
70
 
68
71
  ### Important note about debian 12:
69
- If you use system pip to install pyhw, you will encounter this problem on debian12 and some related distributions:
72
+ If you use system pip to install pyhw, you will encounter this problem on debian12 and some related distributions (like Ubuntu 24.04):
70
73
  ```text
71
74
  error: externally-managed-environment
72
75
 
@@ -87,14 +90,14 @@ hint: See PEP 668 for the detailed specification.
87
90
  ```
88
91
  This is due to the fact that system python is not supposed to be managed by pip. You can simply use **pipx** to install **pyhw**. Or you can use a virtual environment (venv) or force remove this restriction (not recommended).
89
92
 
90
- ## Supported (Tested) OS
93
+ ## Tested OS
91
94
  * macOS arm64, x86_64
92
- * debian-based distro arm64, x86_64
93
- * RaspberryPi OS arm64
95
+ * Linux arm64, x86_64
96
+ * FreeBSD arm64
94
97
 
95
98
 
96
99
  ## Build from source
97
- Currently, build process relay on swiftc and macOS IOKit framework. To build package from source, you need a mac machine with macOS 11 and newer.
100
+ Currently, build process relay on swiftc and macOS IOKit framework. To build package from source, you need a Mac machine with macOS 11 and newer.
98
101
 
99
102
  ### Dependencies
100
103
  This package was originally implemented in pure python and only depends on the python standard library. However, in subsequent development, the code for the pci part was separated into a separate package **pypci-ng**, which can be obtained using pip (or check out [this](https://github.com/xiaoran007/pypci) GitHub repository).
@@ -119,3 +122,8 @@ Or simply type:
119
122
  make build
120
123
  make install
121
124
  ```
125
+ If you have docker installed, you can test this package through docker by type:
126
+ ```shell
127
+ make test # local build
128
+ make test-pypi # release version
129
+ ```
@@ -1,66 +1,73 @@
1
1
  pyhw/__init__.py,sha256=IMjkMO3twhQzluVTo8Z6rE7Eg-9U79_LGKMcsWLKBkY,22
2
- pyhw/__main__.py,sha256=3iVi-P0ciOYQPUrelB48gGOWlzFFkEw8n7MzX1K5Pck,1765
3
- pyhw/macos.py,sha256=kF973QvtEFky4m8RnYTJ-HWPuJi3625tvnWqJAT_DHM,4598
2
+ pyhw/__main__.py,sha256=A0t0jkcwdTXd6ca7POUfm8krjCn2FQaXTIss5gNmNcI,1775
4
3
  pyhw/backend/__init__.py,sha256=knn_3Yroow1h0dqdrozk3zyy3vz-kQyNBRjR6OLmVoY,50
5
4
  pyhw/backend/backendBase.py,sha256=mloo8mPEbgbIdmyQ3I4vdEXMSSjxWi_wnwACmzvHbEo,506
6
5
  pyhw/backend/cpu/__init__.py,sha256=5YfANJVRwNwTRodG0ENOgusrdN592aaSnfq5ok4dKTo,56
7
- pyhw/backend/cpu/cpuBase.py,sha256=AGWqVjdvb82NiH4kxk3GERdBLwBNhkR23j2ei_l3S18,464
6
+ pyhw/backend/cpu/bsd.py,sha256=Ls97NAsvZGVJj3_fBUcYXjY2gsZvFKhXYtkTHxVVXSs,288
7
+ pyhw/backend/cpu/cpuBase.py,sha256=u9kQORv8RJ9BLjG219wNTgBAivHy_lUll4Bkk6TBlXY,576
8
8
  pyhw/backend/cpu/cpuInfo.py,sha256=A_nNGElq9W7oZ5DFJowLdFBE0ZvXKr5h29E6TGAvbRc,251
9
9
  pyhw/backend/cpu/linux.py,sha256=zJ2cOwQHtolJrMMY1WXVbLLIRNPxeClUgzLAAkd7As4,3346
10
10
  pyhw/backend/cpu/macos.py,sha256=pacU-yT7q-HKerkh2Q0BSdzSY6dKzHfSnRZBmimqqXk,2953
11
11
  pyhw/backend/gpu/__init__.py,sha256=EpMjPvUaXt0LTNMvGmB8WgXbUB9keCxuOhu8NT3Re6o,56
12
- pyhw/backend/gpu/gpuBase.py,sha256=Ge0DX2P8_EB7ovM7glmPUnVsPJL3OUHV2t_1T5mimR0,409
12
+ pyhw/backend/gpu/bsd.py,sha256=hNFiCek770CXOh3DK3I3-g272-a1S5D7LolGJBsLXaU,124
13
+ pyhw/backend/gpu/gpuBase.py,sha256=DyY1bVrsaWczkbrrN6J7kG-Kh9yic3Lqww8yLZNCet8,521
13
14
  pyhw/backend/gpu/gpuInfo.py,sha256=d_z_z5DiZAg85wP0VOBQEU0QHdaK3qFqA2Tp9Eq8-Zs,133
14
15
  pyhw/backend/gpu/linux.py,sha256=E-evoL-spQbHB8JvbZXSq5ypc2SeePVUPnhEQrSPQpg,1619
15
16
  pyhw/backend/gpu/macos.py,sha256=SmTqqTrIMRW-GVPmDs8xAiOX7HsCjrGh9qkxLQCdvO8,3850
16
17
  pyhw/backend/host/__init__.py,sha256=Efaj7-Oya7H8HdpZHQCLrwn-mcfPb-d6yfh4dzsE_7I,58
17
- pyhw/backend/host/hostBase.py,sha256=POyDW3f5JSWtEKyCfrVSBEddSwoywe_OBgUExCEuje8,563
18
+ pyhw/backend/host/bsd.py,sha256=9gKnM6yysHBKwS3EQvb0pCeylh3dzHvoEuPe14zo9wQ,382
19
+ pyhw/backend/host/hostBase.py,sha256=Dt3zZjkL6iUM9eOKkPUBAZ_2Lx-GQSIjsQhkLmjCUAk,678
18
20
  pyhw/backend/host/hostInfo.py,sha256=Xvz0LugPiCSWMkcDsp4p2rrojYFZauL6Q-gCZ6NLz5k,184
19
- pyhw/backend/host/linux.py,sha256=5wfEbe4au4JqDazBuUTfWLC2sPPa_YuidSGKVwzyI-0,2853
21
+ pyhw/backend/host/linux.py,sha256=vGIl1b61vB-uilPk6awPOIWRaxnIsR43L20sNHeM5bI,2824
20
22
  pyhw/backend/host/macos.py,sha256=KW-EJK9g1xHNrFsVxJv5GPLpc_ZevX0Zv1WjZUzRkzo,15369
21
23
  pyhw/backend/host/windows.py,sha256=rjDJaIs-5zspzFsNCMCh6m2yZXEXI0vccqeBpmAdEBk,53
22
24
  pyhw/backend/kernel/__init__.py,sha256=fGjwjpOhwA_PnsWbwoq102hwhTay2ufYKaTqxjSV2-I,65
23
- pyhw/backend/kernel/kernelBase.py,sha256=CMvBszl4_aP48YWnFI03I2GtngYStkcY4uDU3ub8C3E,555
25
+ pyhw/backend/kernel/kernelBase.py,sha256=ZUj5wqar9mLUlIYrTDzyCWjrwzGtP6WJIIAXy5v1zhM,490
24
26
  pyhw/backend/kernel/kernelInfo.py,sha256=QQYni0IVeFZ2IVNDC06U728Q01Rq3R6qRDYCxMjtJrY,189
25
27
  pyhw/backend/kernel/unix.py,sha256=XDV2GIjamERcmlrQFaKFZY-OJO1xj76Im_7lmg2uFzo,1192
26
28
  pyhw/backend/kernel/windows.py,sha256=lxZ7T9Ea0Qbq3pf_TjSAHSM2YTozC6ivv7dKdLOTl3s,58
27
29
  pyhw/backend/memory/__init__.py,sha256=zGBWxfPAAk8ivCBWPLJIpuD-lB7wUJT3x8u2jHiAoCY,65
28
- pyhw/backend/memory/linux.py,sha256=eEH3oOYdbANw2B0Ce32fDOidh1GhtEd_UPIo2GohBEA,929
30
+ pyhw/backend/memory/bsd.py,sha256=GKTCs6RocdoWj-5ZZRMB4xAWGWljor6leuwX-L-7bW0,251
31
+ pyhw/backend/memory/linux.py,sha256=kxP0LxXdTWYRtu9nDyKqZeIzZrQI84kVOPMeN1GwSOo,917
29
32
  pyhw/backend/memory/macos.py,sha256=ur2HxmmmVkXmaxEcw_otphifVp_csfNMJdgt-idCq7M,2770
30
- pyhw/backend/memory/memoryBase.py,sha256=RFRWTByH25T3T77maxLyIRRoedIi5M8XLtVbvwBmjfY,433
33
+ pyhw/backend/memory/memoryBase.py,sha256=wl6zN3-U_jRNsaWM9szWPvWjiq3Ca8Rcm-aMRdAJge8,554
31
34
  pyhw/backend/memory/memoryInfo.py,sha256=OQF165uEyuapAsi7cKacQYDRnKdrQHeldfyFwzS9N2g,186
32
35
  pyhw/backend/metal/t.py,sha256=52yv-JoXNfaIOfcxEEidIg0MoyFtzWvTRm550kQKPZA,391
33
36
  pyhw/backend/nic/__init__.py,sha256=eP4eOYIvMF3LcTf954hJa6TnB8R4Qahss2g-UcgypKY,57
34
- pyhw/backend/nic/linux.py,sha256=2IDhesM77qLt7QK8HzYiMeLyuKWOVVrrDtkLHs7R6lU,1321
37
+ pyhw/backend/nic/bsd.py,sha256=lIXnPqzSA2qexUt0P9OHMmxoI5c5XBi2V80RY9S0wsM,135
38
+ pyhw/backend/nic/linux.py,sha256=vS-bZSvPOjNaPLO6wyJHILVEsEVJJK2aQ4wUcXsgm74,1308
35
39
  pyhw/backend/nic/macos.py,sha256=63gZjSmUGwGqfs41IWrEXmSz9O8eQy4G5oql3JLZmoo,855
36
- pyhw/backend/nic/nicBase.py,sha256=hmVbiPOrDFClQrOBgAUgE8GVkC5nVH280jnlb65CDV4,539
40
+ pyhw/backend/nic/nicBase.py,sha256=cT_rxqIEcvvKFsvjKlkCJ8RIfp7QHxDE9_SImXDae0s,735
37
41
  pyhw/backend/nic/nicInfo.py,sha256=wuBuL-aIzD441IUDPGz5e0xctcZ-opdpgqkVxgbvZLg,133
38
42
  pyhw/backend/npu/__init__.py,sha256=PgLKbwpgT5vw9xpa294Zxb94McyxNXW46_vMbT2Iqyc,58
39
- pyhw/backend/npu/linux.py,sha256=eQLozhGOh3iHoFXdRYp_Fn9OsrmJ7tsyxcOPUvopOSw,1286
43
+ pyhw/backend/npu/bsd.py,sha256=eKkOWZ4MBybR_KOGGcsWUpzCGgghhvuBy5VNsnEE8cI,134
44
+ pyhw/backend/npu/linux.py,sha256=mXHSYRION3pghwk6_4vgHxjSkNxI68ksGLkFZstR0mc,1192
40
45
  pyhw/backend/npu/macos.py,sha256=mNnfvjjPQNlA-mViuhmfeb__uI1be93ZSZvv7PVD52s,1037
41
- pyhw/backend/npu/npuBase.py,sha256=6lPYmsOGHO-lT-GqaJ2hNXRV_FLYqguuZ_7L6JJCG-g,411
46
+ pyhw/backend/npu/npuBase.py,sha256=qiioBmHDeh2Et1F7lwmNight-2W32C0VmMtx2DIOCz4,523
42
47
  pyhw/backend/npu/npuInfo.py,sha256=82dK6XvW_XKw4O5-RfR4-qQRR7Plh8qqJLj0YDzISmU,135
43
48
  pyhw/backend/os/__init__.py,sha256=rPHQYdQK3qU6ZwwodqVoEWeqBnKffXlJyi4k3-8ViPY,53
44
- pyhw/backend/os/linux.py,sha256=UDUSbCMQQJZqfRFHS270u-ZrW4KfqZxcS_vQZl6VbPo,1977
49
+ pyhw/backend/os/bsd.py,sha256=5Q30mkFKdhuup1dRjTEVN58MEGcj7JzbUzh40ld6C14,131
50
+ pyhw/backend/os/linux.py,sha256=U7dIOKZaG5MSw0S65hAfDfFaBMvbwSCHFIHTwckU9iI,1957
45
51
  pyhw/backend/os/macos.py,sha256=DwgpwRD1a2oTANR_XL3kkMzNawqrt23F79dqBw3ULK8,1906
46
- pyhw/backend/os/osBase.py,sha256=AA17HIwmWy7E6nCtqbojTNsHKtcNuehf51FxGcfXu7A,462
52
+ pyhw/backend/os/osBase.py,sha256=IiyrA5IEtlcaR-xigi8SxD70BimFKCBMjgF0MLihSOk,573
47
53
  pyhw/backend/os/osInfo.py,sha256=iLPc7INFHH3izascwooj4JBVgvBsSgVPXWBlFXG47mQ,378
48
54
  pyhw/backend/shell/__init__.py,sha256=SeQ7OLNSl_V1JCCWnJGjLilAWiSe9e5kgsMEt63TMS0,62
49
- pyhw/backend/shell/shellBase.py,sha256=mylNazVtTbCSzus-IPe1QwnuIGSFNP-z5vYKwTIl_yg,377
50
- pyhw/backend/shell/unix.py,sha256=Yradj6aj4nqc9CNQvVqzOgwO-p2IIJ_Jt_okL7cF4as,2146
55
+ pyhw/backend/shell/shellBase.py,sha256=U4HPg_iWhAqaLceBnEVMHFj4A-FNYu7JjsQyi2seEU4,377
56
+ pyhw/backend/shell/unix.py,sha256=Vt2wSxAIrzN679v0MjJwBoK6L12OqZOichociFZ9lw8,2109
51
57
  pyhw/backend/title/__init__.py,sha256=l6_WqreSBeK7krapCrbrr4ndnydrXB1aZ50Ve-beV_w,62
52
- pyhw/backend/title/titleBase.py,sha256=pcnkiNn9N69yc4iicAmpMpC6G7HUMyGCh0V1jjGIP_c,495
58
+ pyhw/backend/title/titleBase.py,sha256=nzHcVJqAMZqWJP101YWgRwilSiZ_hHiK-jiI90Pm3r8,495
53
59
  pyhw/backend/title/unix.py,sha256=9B-zLE8yhlWBnJ-6Aa-DmFmgMV9KdvvNU40drJIaNck,837
54
60
  pyhw/backend/title/windows.py,sha256=5bXR6yxHk3diVx92sjxPeD6fUVR5sKZJG3K4aM3CGn8,82
55
61
  pyhw/backend/uptime/__init__.py,sha256=X8RVhHWmHpyey0C4gcmrt_u1cHKowhAQRDMAxY3i7p0,65
62
+ pyhw/backend/uptime/bsd.py,sha256=XdLIvivr78Pr8PqSwQG3eLvjjaM52nK5QcWrwtuNZlg,147
56
63
  pyhw/backend/uptime/linux.py,sha256=Sh05CgUjAOzPM8LSoZf4fCU-Cl5pwhSJSC7XJ-jFaHU,1027
57
- pyhw/backend/uptime/macos.py,sha256=8lTlR0WUzgGqUNspqegg4dP_j5ySOCTyFlXpyRBJ-Jw,1306
58
- pyhw/backend/uptime/uptimeBase.py,sha256=cP6aTPnFe6XQHgBX7YcDuuGHARI11ctMlyrrtsU-Opc,657
64
+ pyhw/backend/uptime/macos.py,sha256=Io-JrFjmRWHgB7uh4mBTV4rnfJuUvepGh2uiKNhUZcc,1293
65
+ pyhw/backend/uptime/uptimeBase.py,sha256=PB0SWpsZyNz5GL5n39rC7DDSpKVAlH2K2eKqOuiEfy0,778
59
66
  pyhw/backend/uptime/uptimeInfo.py,sha256=TobPEV3MBT3Fiv3W6TOzD3a4MNW-vz2Oi_Trlcihu7k,114
60
67
  pyhw/frontend/__init__.py,sha256=xgv_iVv9w4cLXklbdtFWXu7J7KJxBCUw-ZcUQb_abFc,57
61
- pyhw/frontend/frontendBase.py,sha256=t_lq2mvBet3l8Kn7bvab1bvfwCaD7PZ6dzN8fMCzHOI,4713
68
+ pyhw/frontend/frontendBase.py,sha256=rPAf7tE1u8uGgZ-mDTOw_O2S2-YsevEzGJsq34eJlXQ,4957
62
69
  pyhw/frontend/color/__init__.py,sha256=xk511qWwdYWEVjk_zOaC4fs81HtwR4ELr3wi1tTL824,191
63
- pyhw/frontend/color/colorConfig.py,sha256=3k6aMoU7ymThG3yytzKqQDDxz8xL5wfZL_2cDiPusXI,4353
70
+ pyhw/frontend/color/colorConfig.py,sha256=6VADbaM_xwlYF4Ds38xvmRgxVSDWBB71WWDFhiLrQaI,4650
64
71
  pyhw/frontend/color/colorSet.py,sha256=spH8PlRu7capouf-yUgDHgoPCnM5aJ_ncascISZfz2g,1421
65
72
  pyhw/frontend/color/colorUtil.py,sha256=VhcPmAJmXGIiRBfVZE2jg_iy-SfbxqwOSvkRz-nbUOQ,94
66
73
  pyhw/frontend/logo/__init__.py,sha256=mozEarHueBUgtDHKSd-RDaFysMLUiW3VQ8KcBtlKGCI,47
@@ -72,6 +79,7 @@ pyhw/frontend/logo/ascii/centos.pyhw,sha256=t-pFKQslIAKN4Jl1ilKLzB79BHSi0_zaJUDG
72
79
  pyhw/frontend/logo/ascii/debian.pyhw,sha256=ZmO1fg3Uc_ofF-CZSOP0Qo298luDASh2Zt50UmY6DBQ,437
73
80
  pyhw/frontend/logo/ascii/fedora.pyhw,sha256=IuFE6BByaNfVgn1pn7rKH7QVlIJyEmgGopCAOpXa6oM,742
74
81
  pyhw/frontend/logo/ascii/fedora_small.pyhw,sha256=_LSBzuCJjMa8pzmiJ3KN7Ndi-TryYPmtEfKqxxPAFfE,601
82
+ pyhw/frontend/logo/ascii/freebsd.pyhw,sha256=Socjz8LCxWDpIaFjfISHX5TjlmWLtXTYqci6-m6hzJY,514
75
83
  pyhw/frontend/logo/ascii/linux.pyhw,sha256=IMe6YNElwCjLtv6kgSkERbATyyJAK531vcrT-otaLWE,300
76
84
  pyhw/frontend/logo/ascii/macOS.pyhw,sha256=HBGROtBb7wrNtRqAQ9ND7zxK0l17BRsmpgc2dMo_m6s,474
77
85
  pyhw/frontend/logo/ascii/raspbian.pyhw,sha256=jEl6WMKF-FGx359ipQ1kzweUJS-NuauYQCFaYime4PQ,159
@@ -81,11 +89,11 @@ pyhw/library/lib/iokitGPULib.dylib,sha256=DcJ0GZY79gTFckLFYtZgeKn1T0NFvdO_k_ccCa
81
89
  pyhw/pyhwException/__init__.py,sha256=8JsFvtF13g0Y5t4z9fRndDXtfCzuBM59jDf6PhWSFSk,220
82
90
  pyhw/pyhwException/pyhwException.py,sha256=wxuzFQa9g7XB1q9TUKO_55lw7wMEJMpzG8w1GVTFVa0,197
83
91
  pyhw/pyhwUtil/__init__.py,sha256=diIqlNUBfuHu-2VAOJk5nipGLafnWxR3chAAOmX8QRo,250
84
- pyhw/pyhwUtil/pyhwUtil.py,sha256=OY89sHr5LBjob7JMbCl-6x1AEPr-15UOE8UoQ04sLvI,5968
92
+ pyhw/pyhwUtil/pyhwUtil.py,sha256=X8m49FHR56QLmkF2rJodH9wtpLZWYrRs9Hc7lBD3G_s,6297
85
93
  pyhw/pyhwUtil/sysctlUtil.py,sha256=S-rUvqi7ZrMyMouIhxlyHEQ4agM7sCT1Y7uzs3Hu5-o,841
86
- pyhw-0.6.7.dist-info/LICENSE,sha256=hJs6RBqSVCexbTsalkMLNFI5t06kekQEsSVaOt_-yLs,1497
87
- pyhw-0.6.7.dist-info/METADATA,sha256=NL0A7juUgOQRXCkDyg32z1NXzAFq8AF2drk4FSrkJi8,5225
88
- pyhw-0.6.7.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
89
- pyhw-0.6.7.dist-info/entry_points.txt,sha256=q-AB8im_QahpmNrmy4aPTJRGi0LlbNlnI3kF7s6pKss,44
90
- pyhw-0.6.7.dist-info/top_level.txt,sha256=7Inxvxt1TngEricKZEex9_WJZS3DbKYFUXDz4v5WHYU,5
91
- pyhw-0.6.7.dist-info/RECORD,,
94
+ pyhw-0.7.0.dist-info/LICENSE,sha256=hJs6RBqSVCexbTsalkMLNFI5t06kekQEsSVaOt_-yLs,1497
95
+ pyhw-0.7.0.dist-info/METADATA,sha256=fI3DwfOv4xwuWSCuJSa_4yIb1gTGQ-VHyDA3Gq25TcM,5430
96
+ pyhw-0.7.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
97
+ pyhw-0.7.0.dist-info/entry_points.txt,sha256=q-AB8im_QahpmNrmy4aPTJRGi0LlbNlnI3kF7s6pKss,44
98
+ pyhw-0.7.0.dist-info/top_level.txt,sha256=7Inxvxt1TngEricKZEex9_WJZS3DbKYFUXDz4v5WHYU,5
99
+ pyhw-0.7.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.5.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
pyhw/macos.py DELETED
@@ -1,146 +0,0 @@
1
- import subprocess
2
- import json
3
- import platform
4
- from pyhwException import GPUNotFoundException, BackendException
5
-
6
-
7
- class GPUInfo:
8
- def __init__(self, verbose=False):
9
- self._gpus = list()
10
- self._verbose = verbose
11
-
12
- def init(self):
13
- pass
14
-
15
- def _get_gpu_info(self):
16
- try:
17
- gpus = json.loads(subprocess.check_output(["system_profiler", "SPDisplaysDataType", "-json"])).get('SPDisplaysDataType')
18
- if gpus is not None:
19
- if self._verbose:
20
- print(f"Detected {len(gpus)} GPU(s).")
21
- else:
22
- raise GPUNotFoundException("No GPU information found.")
23
- except Exception as e:
24
- raise BackendException(f"An error occurred while getting GPU info: {e}")
25
-
26
- gpu_info_list = list()
27
-
28
- for i in range(len(gpus)):
29
- gpu = gpus[i]
30
- info = dict()
31
- info["name"] = gpu.get("sppci_model")
32
- if gpu.get("spdisplays_vendor") == "sppci_vendor_Apple":
33
- info["vram"] = f"{get_mem_info()} (shared memory)"
34
- else:
35
- info["vram"] = gpu.get("spdisplays_vram")
36
- info["vendor"] = gpu.get("spdisplays_vendor")
37
- info["cores"] = gpu.get("sppci_cores")
38
- info["metal"] = gpu.get("spdisplays_mtlgpufamilysupport")
39
- info["bus"] = gpu.get("sppci_bus")
40
- info["link"] = gpu.get("spdisplays_pcie_width")
41
- gpu_info_list.append(info)
42
-
43
- @staticmethod
44
- def _handleVendor(vendor):
45
- if vendor == "sppci_vendor_Apple":
46
- return "Apple"
47
- elif vendor == "sppci_vendor_intel":
48
- return "Intel"
49
- elif vendor == "sppci_vendor_amd":
50
- return "AMD"
51
- else:
52
- return vendor
53
-
54
- @staticmethod
55
- def _handleVram(vram, vendor):
56
- if vendor == "Apple":
57
- return f"{get_mem_info()} (shared memory)"
58
- else:
59
- return vram
60
-
61
- @staticmethod
62
- def _getVramApple():
63
- try:
64
- return json.loads(subprocess.check_output(["system_profiler", "SPHardwareDataType", "-json"]))["SPHardwareDataType"][0]["physical_memory"]
65
- except Exception as e:
66
- raise BackendException(f"An error occurred while getting memory info: {e}")
67
-
68
-
69
- class GPU:
70
- def __init__(self):
71
- self._name = str()
72
- self._vram = str()
73
- self._vendor = str()
74
- self._cores = str()
75
- self._metal = str()
76
- self._bus = str()
77
- self._bus_width = str()
78
- self._id = int()
79
-
80
- def init(self):
81
- pass
82
-
83
- def _get_gpu_info(self):
84
- pass
85
-
86
-
87
-
88
-
89
- def get_mem_info():
90
- try:
91
- mem_info_dict = json.loads(subprocess.check_output(["system_profiler", "SPHardwareDataType", "-json"]))
92
- mem_info = mem_info_dict["SPHardwareDataType"][0]["physical_memory"]
93
- return mem_info
94
- except Exception as e:
95
- print(f"An error occurred while getting memory info: {e}")
96
- exit(-1)
97
-
98
-
99
- def get_gpu_info():
100
- gpus = list()
101
- try:
102
- gpu_info_dict = json.loads(subprocess.check_output(["system_profiler", "SPDisplaysDataType", "-json"]))
103
- if 'SPDisplaysDataType' in gpu_info_dict:
104
- gpus = gpu_info_dict['SPDisplaysDataType']
105
- print(f"Detected {len(gpus)} GPU(s).")
106
- else:
107
- print("No GPU information found.")
108
- except Exception as e:
109
- print(f"An error occurred while getting GPU info: {e}")
110
- exit(-1)
111
-
112
- gpu_info_list = list()
113
-
114
- for i in range(len(gpus)):
115
- gpu = gpus[i]
116
- info = dict()
117
- info["name"] = gpu.get("sppci_model")
118
- if gpu.get("spdisplays_vendor") == "sppci_vendor_Apple":
119
- info["vram"] = f"{get_mem_info()} (shared memory)"
120
- else:
121
- info["vram"] = gpu.get("spdisplays_vram")
122
- info["vendor"] = gpu.get("spdisplays_vendor")
123
- info["cores"] = gpu.get("sppci_cores")
124
- info["metal"] = gpu.get("spdisplays_mtlgpufamilysupport")
125
- info["bus"] = gpu.get("sppci_bus")
126
- info["link"] = gpu.get("spdisplays_pcie_width")
127
- gpu_info_list.append(info)
128
- return gpu_info_list
129
-
130
-
131
- if __name__ == "__main__":
132
- li = get_gpu_info()
133
- for i in range(len(li)):
134
- info = li[i]
135
- print('----------')
136
- print(f"GPU {i}:")
137
- print(f'name: {info["name"]}')
138
- print(f'vram: {info["vram"]}')
139
- print(f'vendor: {info["vendor"]}')
140
- print(f'cores: {info["cores"]}')
141
- print(f'metal: {info["metal"]}')
142
- print(f'bus: {info["bus"]}')
143
- print(f'link: {info["link"]}')
144
-
145
- print('----------')
146
-
File without changes