pyhw 0.3.6__py3-none-any.whl → 0.4.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
pyhw/backend/gpu/linux.py CHANGED
@@ -2,6 +2,7 @@ import subprocess
2
2
  from .gpuInfo import GPUInfo
3
3
  from ..cpu import CPUDetect
4
4
  from ...pyhwUtil import getArch
5
+ import pypci
5
6
 
6
7
 
7
8
  class GPUDetectLinux:
@@ -14,19 +15,17 @@ class GPUDetectLinux:
14
15
  return self.__gpuInfo
15
16
 
16
17
  def __getGPUInfo(self):
17
- try:
18
- pci_info = subprocess.run(["bash", "-c", "lspci"], capture_output=True, text=True).stdout.strip()
19
- except subprocess.SubprocessError:
20
- return
21
- if len(pci_info) == 0: # no pcie devices found
18
+ gpu_devices = pypci.PCI().FindAllVGA()
19
+ if len(gpu_devices) == 0:
22
20
  self.__handleNonePciDevices()
23
- for line in pci_info.split("\n"):
24
- if "VGA" in line or "Display" in line or "3D " in line:
25
- gpu = line.split(": ")[1]
26
- self.__gpuInfo.gpus.append(self.__gpuNameClean(gpu))
21
+ else:
22
+ for device in gpu_devices:
23
+ if device.subsystem_device_name != "":
24
+ device_name = f"{device.vendor_name} {device.device_name} ({device.subsystem_device_name})"
25
+ else:
26
+ device_name = f"{device.vendor_name} {device.device_name}"
27
+ self.__gpuInfo.gpus.append(self.__gpuNameClean(device_name))
27
28
  self.__gpuInfo.number += 1
28
- if self.__gpuInfo.number == 0:
29
- self.__handleNonePciDevices() # fallback to a sbc device detection method
30
29
 
31
30
  def __handleNonePciDevices(self):
32
31
  # if detector can't find any VGA/Display/3D GPUs, assume the host is a sbc device, this function is a placeholder for a more advanced method.
pyhw/backend/nic/linux.py CHANGED
@@ -2,6 +2,7 @@ import subprocess
2
2
  from .nicInfo import NICInfo
3
3
  from ...pyhwUtil import getArch
4
4
  from ...pyhwException import BackendException
5
+ import pypci
5
6
 
6
7
 
7
8
  class NICDetectLinux:
@@ -14,20 +15,17 @@ class NICDetectLinux:
14
15
  return self.__nicInfo
15
16
 
16
17
  def __getNICInfo(self):
17
- try:
18
- pci_info = subprocess.run(["bash", "-c", "lspci"], capture_output=True, text=True).stdout.strip()
19
- except subprocess.SubprocessError:
20
- return
21
- if len(pci_info) == 0: # no pcie devices found
18
+ nic_devices = pypci.PCI().FindAllNIC()
19
+ if len(nic_devices) == 0:
22
20
  self.__handleNonePciDevices()
23
- return
24
- for line in pci_info.split("\n"):
25
- if "Ethernet controller" in line or "Network controller" in line:
26
- nic = line.split(": ")[1]
27
- self.__nicInfo.nics.append(self.__nicNameClean(nic))
21
+ else:
22
+ for device in nic_devices:
23
+ if device.subsystem_device_name != "":
24
+ device_name = f"{device.vendor_name} {device.device_name} ({device.subsystem_device_name})"
25
+ else:
26
+ device_name = f"{device.vendor_name} {device.device_name}"
27
+ self.__nicInfo.nics.append(self.__nicNameClean(device_name))
28
28
  self.__nicInfo.number += 1
29
- if self.__nicInfo.number == 0:
30
- self.__handleNonePciDevices() # fallback to usb detection method
31
29
 
32
30
  def __handleNonePciDevices(self):
33
31
  # placeholder for a more advanced method.
@@ -40,4 +38,4 @@ class NICDetectLinux:
40
38
  return nic_name_clean
41
39
 
42
40
  def __sortNICList(self):
43
- return self.__nicInfo.nics.sort()
41
+ return self.__nicInfo.nics.sort()
@@ -0,0 +1,18 @@
1
+ from .nicInfo import NICInfo
2
+ import subprocess
3
+
4
+
5
+ class NICDetectMacOS:
6
+ def __init__(self):
7
+ self.__nicInfo = NICInfo()
8
+
9
+ def getNICInfo(self):
10
+ self.__nicInfo.nics.append("en0")
11
+ self.__nicInfo.number = 1
12
+ return self.__nicInfo
13
+
14
+ def __getNICInfo(self):
15
+ # Placeholder for a more advanced method.
16
+ interfaces = subprocess.run(["bash", "-c", "route get default | grep interface"], capture_output=True, text=True).stdout.strip()
17
+
18
+
@@ -1,4 +1,5 @@
1
1
  from .linux import NICDetectLinux
2
+ from .macos import NICDetectMacOS
2
3
 
3
4
 
4
5
  class NICDetect:
@@ -14,4 +15,6 @@ class NICDetect:
14
15
  :return: dataclass NICInfo, direct attr: nics
15
16
  """
16
17
  if self.OS == "linux":
17
- return NICDetectLinux().getNICInfo()
18
+ return NICDetectLinux().getNICInfo()
19
+ elif self.OS == "macos":
20
+ return NICDetectMacOS().getNICInfo()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyhw
3
- Version: 0.3.6
3
+ Version: 0.4.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
@@ -13,6 +13,7 @@ Classifier: Operating System :: OS Independent
13
13
  Requires-Python: >=3.9
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
+ Requires-Dist: pypci-ng>=0.0.1
16
17
 
17
18
  # PyHw
18
19
  [![Downloads](https://static.pepy.tech/badge/pyhw)](https://pepy.tech/project/pyhw)
@@ -27,7 +28,9 @@ PyHw, a neofetch-like command line tool for fetching system information but writ
27
28
  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 🤔).
28
29
 
29
30
 
30
- ![demo](https://i2.imgs.ovh/d/BQACAgUAAx0EUvSR8wACMvpmyFVohzKxLcUdLiJaEa3wlo_OrQACuw4AAoX-QVaSpG0-rTAeRTUE)
31
+ [//]: # (![demo]&#40;https://i2.imgs.ovh/d/BQACAgUAAx0EUvSR8wACMvpmyFVohzKxLcUdLiJaEa3wlo_OrQACuw4AAoX-QVaSpG0-rTAeRTUE&#41;)
32
+ ![demo](https://files.catbox.moe/xx58xy.jpg)
33
+
31
34
 
32
35
 
33
36
 
@@ -11,7 +11,7 @@ pyhw/backend/cpu/macos.py,sha256=mnnH9ABiBgAiyA8-H9_tq2PC5OeneVLj67nMGoLDXh4,287
11
11
  pyhw/backend/gpu/__init__.py,sha256=EpMjPvUaXt0LTNMvGmB8WgXbUB9keCxuOhu8NT3Re6o,56
12
12
  pyhw/backend/gpu/gpuBase.py,sha256=Ge0DX2P8_EB7ovM7glmPUnVsPJL3OUHV2t_1T5mimR0,409
13
13
  pyhw/backend/gpu/gpuInfo.py,sha256=d_z_z5DiZAg85wP0VOBQEU0QHdaK3qFqA2Tp9Eq8-Zs,133
14
- pyhw/backend/gpu/linux.py,sha256=Pc9Sajf0tgRyT9zP1lYysQciLmgtNZjsuJNH3xNvwAY,1715
14
+ pyhw/backend/gpu/linux.py,sha256=E-evoL-spQbHB8JvbZXSq5ypc2SeePVUPnhEQrSPQpg,1619
15
15
  pyhw/backend/gpu/macos.py,sha256=kkTq9_ZJwTQ0Jwep4oYq41STDTplFz83jKRYbvlbMhg,2337
16
16
  pyhw/backend/host/__init__.py,sha256=Efaj7-Oya7H8HdpZHQCLrwn-mcfPb-d6yfh4dzsE_7I,58
17
17
  pyhw/backend/host/hostBase.py,sha256=POyDW3f5JSWtEKyCfrVSBEddSwoywe_OBgUExCEuje8,563
@@ -31,8 +31,9 @@ pyhw/backend/memory/memoryBase.py,sha256=RFRWTByH25T3T77maxLyIRRoedIi5M8XLtVbvwB
31
31
  pyhw/backend/memory/memoryInfo.py,sha256=OQF165uEyuapAsi7cKacQYDRnKdrQHeldfyFwzS9N2g,186
32
32
  pyhw/backend/metal/t.py,sha256=52yv-JoXNfaIOfcxEEidIg0MoyFtzWvTRm550kQKPZA,391
33
33
  pyhw/backend/nic/__init__.py,sha256=eP4eOYIvMF3LcTf954hJa6TnB8R4Qahss2g-UcgypKY,57
34
- pyhw/backend/nic/linux.py,sha256=xWZQlPfeQK9vbn3vQvm-liEJ1Zu1LGwkVhGrzJO1jjc,1436
35
- pyhw/backend/nic/nicBase.py,sha256=g68oFWN1cjObAZQZXKtSyz9XVPpuWaTqLsQ8Q0wTO7c,422
34
+ pyhw/backend/nic/linux.py,sha256=2IDhesM77qLt7QK8HzYiMeLyuKWOVVrrDtkLHs7R6lU,1321
35
+ pyhw/backend/nic/macos.py,sha256=Gi-XAf2ZvJcWbwJvTlkpdyKaRDSXXiI2WhISeASxbvc,481
36
+ pyhw/backend/nic/nicBase.py,sha256=hmVbiPOrDFClQrOBgAUgE8GVkC5nVH280jnlb65CDV4,539
36
37
  pyhw/backend/nic/nicInfo.py,sha256=wuBuL-aIzD441IUDPGz5e0xctcZ-opdpgqkVxgbvZLg,133
37
38
  pyhw/backend/os/__init__.py,sha256=rPHQYdQK3qU6ZwwodqVoEWeqBnKffXlJyi4k3-8ViPY,53
38
39
  pyhw/backend/os/linux.py,sha256=UDUSbCMQQJZqfRFHS270u-ZrW4KfqZxcS_vQZl6VbPo,1977
@@ -76,9 +77,9 @@ pyhw/pyhwException/pyhwException.py,sha256=wxuzFQa9g7XB1q9TUKO_55lw7wMEJMpzG8w1G
76
77
  pyhw/pyhwUtil/__init__.py,sha256=PzeP9fXsIhvr3sUpJ4DxW9_H25DEIasBFfXd_NztfR4,226
77
78
  pyhw/pyhwUtil/pyhwUtil.py,sha256=PXibpl4hfc-xFHV1HNWwkzttC0NQITHLEwojYKMmD-U,2413
78
79
  pyhw/pyhwUtil/sysctlUtil.py,sha256=S-rUvqi7ZrMyMouIhxlyHEQ4agM7sCT1Y7uzs3Hu5-o,841
79
- pyhw-0.3.6.dist-info/LICENSE,sha256=hJs6RBqSVCexbTsalkMLNFI5t06kekQEsSVaOt_-yLs,1497
80
- pyhw-0.3.6.dist-info/METADATA,sha256=Sf-ylDNdsZWPPoOvwyvlh97L4VmYx1ZADIdEi6__G9w,4041
81
- pyhw-0.3.6.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
82
- pyhw-0.3.6.dist-info/entry_points.txt,sha256=q-AB8im_QahpmNrmy4aPTJRGi0LlbNlnI3kF7s6pKss,44
83
- pyhw-0.3.6.dist-info/top_level.txt,sha256=7Inxvxt1TngEricKZEex9_WJZS3DbKYFUXDz4v5WHYU,5
84
- pyhw-0.3.6.dist-info/RECORD,,
80
+ pyhw-0.4.0.dist-info/LICENSE,sha256=hJs6RBqSVCexbTsalkMLNFI5t06kekQEsSVaOt_-yLs,1497
81
+ pyhw-0.4.0.dist-info/METADATA,sha256=s9V56kt4Wf7VbhDWvGAfI0RPE0rLSzLAXpTp4H4lpqI,4136
82
+ pyhw-0.4.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
83
+ pyhw-0.4.0.dist-info/entry_points.txt,sha256=q-AB8im_QahpmNrmy4aPTJRGi0LlbNlnI3kF7s6pKss,44
84
+ pyhw-0.4.0.dist-info/top_level.txt,sha256=7Inxvxt1TngEricKZEex9_WJZS3DbKYFUXDz4v5WHYU,5
85
+ pyhw-0.4.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (74.1.2)
2
+ Generator: setuptools (75.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
File without changes