pyhw 0.2.0b0__py3-none-any.whl → 0.7.3__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. pyhw/__init__.py +1 -1
  2. pyhw/__main__.py +10 -3
  3. pyhw/backend/backendBase.py +2 -0
  4. pyhw/backend/cpu/bsd.py +12 -0
  5. pyhw/backend/cpu/cpuBase.py +3 -0
  6. pyhw/backend/cpu/linux.py +26 -0
  7. pyhw/backend/cpu/macos.py +3 -1
  8. pyhw/backend/gpu/bsd.py +7 -0
  9. pyhw/backend/gpu/gpuBase.py +3 -0
  10. pyhw/backend/gpu/linux.py +20 -11
  11. pyhw/backend/gpu/macos.py +54 -17
  12. pyhw/backend/host/bsd.py +13 -0
  13. pyhw/backend/host/hostBase.py +3 -0
  14. pyhw/backend/host/linux.py +48 -21
  15. pyhw/backend/host/macos.py +11 -1
  16. pyhw/backend/kernel/kernelBase.py +1 -3
  17. pyhw/backend/memory/bsd.py +11 -0
  18. pyhw/backend/memory/linux.py +8 -8
  19. pyhw/backend/memory/memoryBase.py +3 -0
  20. pyhw/backend/nic/__init__.py +4 -0
  21. pyhw/backend/nic/bsd.py +7 -0
  22. pyhw/backend/nic/linux.py +41 -0
  23. pyhw/backend/nic/macos.py +27 -0
  24. pyhw/backend/nic/nicBase.py +25 -0
  25. pyhw/backend/nic/nicInfo.py +8 -0
  26. pyhw/backend/npu/__init__.py +5 -0
  27. pyhw/backend/npu/bsd.py +6 -0
  28. pyhw/backend/npu/linux.py +38 -0
  29. pyhw/backend/npu/macos.py +65 -0
  30. pyhw/backend/npu/npuBase.py +20 -0
  31. pyhw/backend/npu/npuInfo.py +10 -0
  32. pyhw/backend/os/bsd.py +7 -0
  33. pyhw/backend/os/linux.py +20 -15
  34. pyhw/backend/os/macos.py +21 -3
  35. pyhw/backend/os/osBase.py +3 -0
  36. pyhw/backend/shell/shellBase.py +1 -1
  37. pyhw/backend/shell/unix.py +20 -2
  38. pyhw/backend/title/titleBase.py +1 -1
  39. pyhw/backend/uptime/bsd.py +7 -0
  40. pyhw/backend/uptime/macos.py +12 -12
  41. pyhw/backend/uptime/uptimeBase.py +3 -0
  42. pyhw/frontend/color/colorConfig.py +70 -1
  43. pyhw/frontend/frontendBase.py +41 -2
  44. pyhw/frontend/logo/ascii/alpine.pyhw +6 -0
  45. pyhw/frontend/logo/ascii/arch.pyhw +19 -0
  46. pyhw/frontend/logo/ascii/armbian.pyhw +14 -0
  47. pyhw/frontend/logo/ascii/centos.pyhw +19 -0
  48. pyhw/frontend/logo/ascii/freebsd.pyhw +15 -0
  49. pyhw/frontend/logo/ascii/raspbian.pyhw +10 -0
  50. pyhw/library/lib/iokitGPULib.dylib +0 -0
  51. pyhw/library/lib/iokitHostLib.dylib +0 -0
  52. pyhw/pyhwUtil/__init__.py +2 -2
  53. pyhw/pyhwUtil/pyhwUtil.py +137 -4
  54. pyhw-0.7.3.dist-info/METADATA +131 -0
  55. pyhw-0.7.3.dist-info/RECORD +100 -0
  56. {pyhw-0.2.0b0.dist-info → pyhw-0.7.3.dist-info}/WHEEL +1 -1
  57. pyhw/macos.py +0 -146
  58. pyhw-0.2.0b0.dist-info/METADATA +0 -50
  59. pyhw-0.2.0b0.dist-info/RECORD +0 -75
  60. {pyhw-0.2.0b0.dist-info → pyhw-0.7.3.dist-info}/LICENSE +0 -0
  61. {pyhw-0.2.0b0.dist-info → pyhw-0.7.3.dist-info}/entry_points.txt +0 -0
  62. {pyhw-0.2.0b0.dist-info → pyhw-0.7.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,38 @@
1
+ from .npuInfo import NPUInfo
2
+ import pypci
3
+
4
+
5
+ class NPUDetectLinux:
6
+ def __init__(self):
7
+ self._npuInfo = NPUInfo()
8
+
9
+ def getNPUInfo(self):
10
+ self._getNPUInfo()
11
+ self._sortNPUList()
12
+ return self._npuInfo
13
+
14
+ def _getNPUInfo(self):
15
+ npu_devices = pypci.PCI().FindAllNPU()
16
+ if len(npu_devices) == 0:
17
+ self._handleNonePciDevices()
18
+ else:
19
+ for device in npu_devices:
20
+ if device.subsystem_device_name != "":
21
+ device_name = f"{device.vendor_name} {device.device_name} ({device.subsystem_device_name})"
22
+ else:
23
+ device_name = f"{device.vendor_name} {device.device_name}"
24
+ self._npuInfo.npus.append(self._npuNameClean(device_name))
25
+ self._npuInfo.number += 1
26
+
27
+ def _handleNonePciDevices(self):
28
+ # Place Holder for unknown NPU
29
+ self._npuInfo.number = 1
30
+ self._npuInfo.npus.append("Not found")
31
+
32
+ @staticmethod
33
+ def _npuNameClean(npu_name: str):
34
+ npu_name_clean = npu_name.replace("Corporation ", "")
35
+ return npu_name_clean
36
+
37
+ def _sortNPUList(self):
38
+ self._npuInfo.npus.sort()
@@ -0,0 +1,65 @@
1
+ from .npuInfo import NPUInfo
2
+ from ...pyhwUtil import getArch, getOS
3
+ import json
4
+ import subprocess
5
+ from ..cpu import CPUDetect
6
+
7
+
8
+ class NPUDetectMacOS:
9
+ def __init__(self):
10
+ self.__npuInfo = NPUInfo()
11
+ self.__arch = getArch()
12
+
13
+ def getNPUInfo(self):
14
+ self.__npuInfo.npus.append(self.__getNPUbyModelName())
15
+ self.__npuInfo.number += 1
16
+ # if self.__arch == "aarch64":
17
+ # self.__getNPUAppleSilicon()
18
+ # else: # Does not consider powerPC based Macs.
19
+ # self.__getNPUIntel()
20
+ return self.__npuInfo
21
+
22
+ def __getNPUAppleSilicon(self):
23
+ # Place holder
24
+ self.__npuInfo.npus.append("Apple Neural Engine [SOC Integrated]")
25
+ self.__npuInfo.number += 1
26
+
27
+ def __getNPUIntel(self):
28
+ # Place holder
29
+ self.__npuInfo.npus.append("Not Found")
30
+ self.__npuInfo.number += 1
31
+
32
+ @staticmethod
33
+ def __handleVendor(vendor):
34
+ if vendor == "sppci_vendor_Apple":
35
+ return "Apple"
36
+ elif vendor == "sppci_vendor_intel":
37
+ return "Intel"
38
+ elif vendor == "sppci_vendor_amd":
39
+ return "AMD"
40
+ else:
41
+ return vendor
42
+
43
+ @staticmethod
44
+ def __getNPUbyModelName():
45
+ # Placeholder
46
+ # see https://apple.fandom.com/wiki/Neural_Engine for more details.
47
+ model_name = CPUDetect(os=getOS()).getCPUInfo().model
48
+ npu = {
49
+ "Apple M1": "Apple Neural Engine 16 Core [SOC Integrated]",
50
+ "Apple M1 Pro": "Apple Neural Engine 16 Core [SOC Integrated]",
51
+ "Apple M1 Max": "Apple Neural Engine 16 Core [SOC Integrated]",
52
+ "Apple M1 Ultra": "Apple Neural Engine 32 Core [SOC Integrated]",
53
+ "Apple M2": "Apple Neural Engine 16 Core [SOC Integrated]",
54
+ "Apple M2 Pro": "Apple Neural Engine 16 Core [SOC Integrated]",
55
+ "Apple M2 Max": "Apple Neural Engine 16 Core [SOC Integrated]",
56
+ "Apple M2 Ultra": "Apple Neural Engine 32 Core [SOC Integrated]",
57
+ "Apple M3": "Apple Neural Engine 16 Core [SOC Integrated]",
58
+ "Apple M3 Pro": "Apple Neural Engine 16 Core [SOC Integrated]",
59
+ "Apple M3 Max": "Apple Neural Engine 16 Core [SOC Integrated]",
60
+ "Apple M4": "Apple Neural Engine 16 Core [SOC Integrated]",
61
+ "Apple M4 Pro": "Apple Neural Engine 16 Core [SOC Integrated]",
62
+ "Apple M4 Max": "Apple Neural Engine 16 Core [SOC Integrated]"
63
+ }
64
+ return npu.get(model_name, "Not Found")
65
+
@@ -0,0 +1,20 @@
1
+ from .linux import NPUDetectLinux
2
+ from .macos import NPUDetectMacOS
3
+ from .bsd import NPUDetectBSD
4
+
5
+
6
+ class NPUDetect:
7
+ def __init__(self, os):
8
+ self.OS = os
9
+
10
+ def getNPUInfo(self):
11
+ if self.OS == "linux":
12
+ return NPUDetectLinux().getNPUInfo()
13
+ elif self.OS == "macos":
14
+ return NPUDetectMacOS().getNPUInfo()
15
+ elif self.OS == "freebsd":
16
+ return NPUDetectBSD().getNPUInfo()
17
+ else:
18
+ raise NotImplementedError("Unsupported operating system")
19
+
20
+
@@ -0,0 +1,10 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass
5
+ class NPUInfo:
6
+ def __init__(self):
7
+ self.number = 0
8
+ self.npus = []
9
+
10
+
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,42 +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
- return self.__osInfo
16
+ self._getOSInfo()
17
+ self._handleArmbian()
18
+ return self._osInfo
18
19
 
19
- def __getOSInfo(self):
20
+ def _getOSInfo(self):
20
21
  try:
21
22
  with open("/etc/os-release", "r") as f:
22
23
  for line in f:
23
24
  key, value = line.strip().split("=")
24
25
  if key == "PRETTY_NAME":
25
- self.__osInfo.prettyName = value.strip('"')
26
+ self._osInfo.prettyName = value.strip('"')
26
27
  elif key == "NAME":
27
- self.__osInfo.name = value.strip('"')
28
+ self._osInfo.name = value.strip('"')
28
29
  elif key == "ID":
29
- self.__osInfo.id = value.strip('"')
30
+ self._osInfo.id = value.strip('"')
30
31
  elif key == "ID_LIKE":
31
- self.__osInfo.idLike = value.strip('"')
32
+ self._osInfo.idLike = value.strip('"')
32
33
  elif key == "VARIANT":
33
- self.__osInfo.variant = value.strip('"')
34
+ self._osInfo.variant = value.strip('"')
34
35
  elif key == "VARIANT_ID":
35
- self.__osInfo.variantID = value.strip('"')
36
+ self._osInfo.variantID = value.strip('"')
36
37
  elif key == "VERSION":
37
- self.__osInfo.version = value.strip('"')
38
+ self._osInfo.version = value.strip('"')
38
39
  elif key == "VERSION_ID":
39
- self.__osInfo.versionID = value.strip('"')
40
+ self._osInfo.versionID = value.strip('"')
40
41
  elif key == "VERSION_CODENAME":
41
- self.__osInfo.versionCodename = value.strip('"')
42
+ self._osInfo.versionCodename = value.strip('"')
42
43
  elif key == "CODE_NAME":
43
- self.__osInfo.codeName = value.strip('"')
44
+ self._osInfo.codeName = value.strip('"')
44
45
  elif key == "BUILD_ID":
45
- self.__osInfo.buildID = value.strip('"')
46
+ self._osInfo.buildID = value.strip('"')
46
47
  except Exception:
47
48
  pass
49
+
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/macos.py CHANGED
@@ -13,7 +13,11 @@ class OSDetectMacOS:
13
13
 
14
14
  def getOSInfo(self):
15
15
  self.__getOS()
16
- self.__osInfo.prettyName = f"{self.__ProductName} {self.__ProductVersion} {self.__BuildVersion} {getArch()}"
16
+ self.__handelOSName()
17
+ if self.__VersionName != "":
18
+ self.__osInfo.prettyName = f"{self.__ProductName} {self.__VersionName} {self.__ProductVersion} {self.__BuildVersion} {getArch()}"
19
+ else:
20
+ self.__osInfo.prettyName = f"{self.__ProductName} {self.__ProductVersion} {self.__BuildVersion} {getArch()}"
17
21
  self.__osInfo.id = "macOS"
18
22
  return self.__osInfo
19
23
 
@@ -32,5 +36,19 @@ class OSDetectMacOS:
32
36
  self.__BuildVersion = sw_ver.split(":")[1].strip()
33
37
 
34
38
  def __handelOSName(self):
35
- # Add os name -- product version conversion logic in the future.
36
- pass
39
+ # Only supports modern macOS
40
+ macOSVersionMap = {
41
+ "11": "Big Sur",
42
+ "12": "Monterey",
43
+ "13": "Ventura",
44
+ "14": "Sonoma",
45
+ "15": "Sequoia"
46
+ }
47
+ if "." in self.__ProductVersion:
48
+ major = self.__ProductVersion.split(".")[0]
49
+ else:
50
+ major = self.__ProductVersion
51
+ version_name = macOSVersionMap.get(major, "")
52
+ if version_name != "":
53
+ self.__VersionName = version_name
54
+
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")
@@ -1,6 +1,7 @@
1
1
  """
2
2
  In dev.
3
3
  """
4
+ from ...pyhwUtil import getDocker
4
5
  from dataclasses import dataclass
5
6
  import os
6
7
  import subprocess
@@ -19,7 +20,10 @@ class ShellDetectUnix:
19
20
  self.__shellInfo = ShellInfoUnix()
20
21
 
21
22
  def getShellInfo(self):
22
- self.__getShell()
23
+ if getDocker():
24
+ self.__getShellDocker()
25
+ else:
26
+ self.__getShell()
23
27
  self.__getVersion()
24
28
  self.__shellInfo.info = self.__shellInfo.shell + " " + self.__shellInfo.version
25
29
  return self.__shellInfo
@@ -31,6 +35,19 @@ class ShellDetectUnix:
31
35
  self.__shellInfo.shell = shell_env.split("/")[-1]
32
36
  self.__shellInfo.path = shell_env
33
37
 
38
+ def __getShellDocker(self):
39
+ try:
40
+ with open("/etc/passwd", "r") as f:
41
+ for line in f:
42
+ if line.startswith("root:"):
43
+ root_shell = line.strip().split(":")[-1]
44
+ break
45
+ except:
46
+ root_shell = ""
47
+ if root_shell != "":
48
+ self.__shellInfo.shell = root_shell.split("/")[-1]
49
+ self.__shellInfo.path = root_shell
50
+
34
51
  def __getVersion(self):
35
52
  shell = self.__shellInfo.shell
36
53
  if shell != "":
@@ -39,7 +56,7 @@ class ShellDetectUnix:
39
56
  elif shell == "bash":
40
57
  try:
41
58
  result = subprocess.run(["bash", "-c", "echo $BASH_VERSION"], capture_output=True, text=True)
42
- self.__shellInfo.version = result.stdout.strip()
59
+ self.__shellInfo.version = result.stdout.strip().split("(")[0]
43
60
  except subprocess.SubprocessError:
44
61
  pass
45
62
  elif shell == "zsh":
@@ -54,3 +71,4 @@ class ShellDetectUnix:
54
71
 
55
72
 
56
73
 
74
+
@@ -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")
@@ -21,13 +21,62 @@ class ColorConfigSet:
21
21
  return ColorConfigSetU.ubuntu
22
22
  elif self.__os_name == "ubuntu_small":
23
23
  return ColorConfigSetU.ubuntu_small
24
+ elif self.__os_name == "raspbian":
25
+ return ColorConfigSetR.raspbian
26
+ elif self.__os_name == "armbian":
27
+ return ColorConfigSetA.armbian
28
+ elif self.__os_name == "alpine":
29
+ return ColorConfigSetA.alpine
30
+ elif self.__os_name == "arch":
31
+ return ColorConfigSetA.arch
32
+ elif self.__os_name == "centos":
33
+ return ColorConfigSetC.centos
34
+ elif self.__os_name == "freebsd":
35
+ return ColorConfigSetF.freebsd
24
36
  else:
25
37
  return ColorConfigSetL.linux # default to Linux
26
38
 
27
39
 
28
40
  @dataclass
29
41
  class ColorConfigSetA:
30
- pass
42
+ armbian = {
43
+ "colors": [
44
+ ColorSet.COLOR_FG_RED
45
+ ],
46
+ "colorKeys": ColorSet.COLOR_FG_YELLOW,
47
+ "colorTitle": ColorSet.COLOR_FG_YELLOW
48
+ }
49
+ alpine = {
50
+ "colors": [
51
+ ColorSet.COLOR_FG_BLUE,
52
+ ColorSet.COLOR_FG_WHITE
53
+ ],
54
+ "colorKeys": ColorSet.COLOR_FG_MAGENTA,
55
+ "colorTitle": ColorSet.COLOR_FG_BLUE
56
+ }
57
+ arch = {
58
+ "colors": [
59
+ ColorSet.COLOR_FG_CYAN,
60
+ ColorSet.COLOR_FG_CYAN
61
+ ],
62
+ "colorKeys": ColorSet.COLOR_FG_CYAN,
63
+ "colorTitle": ColorSet.COLOR_FG_CYAN
64
+ }
65
+
66
+
67
+ @dataclass
68
+ class ColorConfigSetC:
69
+ centos = {
70
+ "colors": [
71
+ ColorSet.COLOR_FG_YELLOW,
72
+ ColorSet.COLOR_FG_GREEN,
73
+ ColorSet.COLOR_FG_BLUE,
74
+ ColorSet.COLOR_FG_MAGENTA,
75
+ ColorSet.COLOR_FG_WHITE
76
+ ],
77
+ "colorKeys": ColorSet.COLOR_FG_GREEN,
78
+ "colorTitle": ColorSet.COLOR_FG_YELLOW
79
+ }
31
80
 
32
81
 
33
82
  @dataclass
@@ -60,6 +109,14 @@ class ColorConfigSetF:
60
109
  "colorKeys": ColorSet.COLOR_FG_BLUE,
61
110
  "colorTitle": ColorSet.COLOR_FG_BLUE
62
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
+ }
63
120
 
64
121
 
65
122
  @dataclass
@@ -90,6 +147,18 @@ class ColorConfigSetM:
90
147
  }
91
148
 
92
149
 
150
+ @dataclass
151
+ class ColorConfigSetR:
152
+ raspbian = {
153
+ "colors": [
154
+ ColorSet.COLOR_FG_RED,
155
+ ColorSet.COLOR_FG_GREEN
156
+ ],
157
+ "colorKeys": ColorSet.COLOR_FG_RED,
158
+ "colorTitle": ColorSet.COLOR_FG_GREEN
159
+ }
160
+
161
+
93
162
  @dataclass
94
163
  class ColorConfigSetU:
95
164
  ubuntu = {
@@ -1,5 +1,8 @@
1
1
  from .logo import Logo
2
2
  from .color import ColorConfigSet, colorPrefix, colorSuffix, ColorSet
3
+ from ..pyhwUtil import getOS
4
+ from ..pyhwException import BackendException
5
+ import os
3
6
  import re
4
7
 
5
8
 
@@ -16,6 +19,7 @@ class Printer:
16
19
  self.__combined_lines = []
17
20
  self.__logo_color_indexes = {}
18
21
  self.__reg = r'\$(\d)'
22
+ self.__columns = self.__getColumns()
19
23
 
20
24
  def cPrint(self):
21
25
  self.__LogoPreprocess()
@@ -29,10 +33,39 @@ class Printer:
29
33
  self.__combined_lines.append(logo_line)
30
34
 
31
35
  for data_line in self.__processed_data_lines[len(self.__processed_logo_lines):]:
32
- self.__combined_lines.append(" " * max_len_logo + data_line)
36
+ self.__combined_lines.append(" " * (max_len_logo + 1) + data_line)
37
+
38
+ self.__dropLongString()
33
39
 
34
40
  print("\n".join(self.__combined_lines))
35
41
 
42
+ def __dropLongString(self):
43
+ # Need more accurate way to drop long strings
44
+ if getOS() == "linux":
45
+ fixed_lines = list()
46
+ for line in self.__combined_lines:
47
+ if len(line) > self.__columns+20:
48
+ fixed_lines.append(line[:self.__columns+20])
49
+ else:
50
+ fixed_lines.append(line)
51
+ self.__combined_lines = fixed_lines
52
+ else:
53
+ pass
54
+
55
+
56
+ @staticmethod
57
+ def __getColumns() -> int:
58
+ if getOS() == "linux":
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
64
+ else:
65
+ # macOS default terminal size is 80 columns
66
+ columns = 80
67
+ return columns
68
+
36
69
  def __LogoPreprocess(self):
37
70
  global_color = self.__config.get("colors")[0]
38
71
  for logo_line in self.__logo_lines:
@@ -63,7 +96,13 @@ class Printer:
63
96
  self.__data_lines[0].split("@")[1] + colorSuffix())
64
97
  self.__processed_data_lines.append(colorSuffix() + self.__data_lines[1])
65
98
  for data_line in self.__data_lines[2:]:
66
- 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")
67
106
  self.__processed_data_lines.append(colorPrefix(ColorSet.COLOR_MODE_BOLD) + colorPrefix(keys_color) + name + ": " + colorSuffix() + value)
68
107
 
69
108
 
@@ -0,0 +1,6 @@
1
+ /\ /\
2
+ // \ \
3
+ // \ \
4
+ /// \ \
5
+ // \ \
6
+ \
@@ -0,0 +1,19 @@
1
+
2
+ ▟█▙
3
+ ▟███▙
4
+ ▟█████▙
5
+ ▟███████▙
6
+ ▂▔▀▜██████▙
7
+ ▟██▅▂▝▜█████▙
8
+ ▟█████████████▙
9
+ ▟███████████████▙
10
+ ▟█████████████████▙
11
+ ▟███████████████████▙
12
+ $2 ▟█████████▛▀▀▜████████▙
13
+ ▟████████▛ ▜███████▙
14
+ ▟█████████ ████████▙
15
+ ▟██████████ █████▆▅▄▃▂
16
+ ▟██████████▛ ▜█████████▙
17
+ ▟██████▀▀▀ ▀▀██████▙
18
+ ▟███▀▘ ▝▀███▙
19
+ ▟▛▀ ▀▜▙
@@ -0,0 +1,14 @@
1
+ █ █ █ █ █ █ █ █ █ █ █
2
+ ███████████████████████
3
+ ▄▄██ ██▄▄
4
+ ▄▄██ ███████████ ██▄▄
5
+ ▄▄██ ██ ██ ██▄▄
6
+ ▄▄██ ██ ██ ██▄▄
7
+ ▄▄██ ██ ██ ██▄▄
8
+ ▄▄██ █████████████ ██▄▄
9
+ ▄▄██ ██ ██ ██▄▄
10
+ ▄▄██ ██ ██ ██▄▄
11
+ ▄▄██ ██ ██ ██▄▄
12
+ ▄▄██ ██▄▄
13
+ ███████████████████████
14
+ █ █ █ █ █ █ █ █ █ █ █
@@ -0,0 +1,19 @@
1
+ ..
2
+ .PLTJ.
3
+ <><><><>
4
+ $2KKSSV' 4KKK $1LJ$4 KKKL.'VSSKK
5
+ $2KKV' 4KKKKK $1LJ$4 KKKKAL 'VKK
6
+ $2V' ' 'VKKKK $1LJ$4 KKKKV' ' 'V
7
+ $2.4MA.' 'VKK $1LJ$4 KKV' '.4Mb.
8
+ $4. $2KKKKKA.' 'V $1LJ$4 V' '.4KKKKK $3.
9
+ $4.4D $2KKKKKKKA.'' $1LJ$4 ''.4KKKKKKK $3FA.
10
+ $4<QDD ++++++++++++ $3++++++++++++ GFD>
11
+ '$4VD $3KKKKKKKK'.. $2LJ $1..'KKKKKKKK $3FV
12
+ $4' $3VKKKKK'. .4 $2LJ $1K. .'KKKKKV $3'
13
+ $3'VK'. .4KK $2LJ $1KKA. .'KV'
14
+ $3A. . .4KKKK $2LJ $1KKKKA. . .4
15
+ $3KKA. 'KKKKK $2LJ $1KKKKK' .4KK
16
+ $3KKSSA. VKKK $2LJ $1KKKV .4SSKK
17
+ $2<><><><>
18
+ $2'MKKM'
19
+ $2''
@@ -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
+ .---.....----.
@@ -0,0 +1,10 @@
1
+ $2.~~. .~~.
2
+ '. \ ' ' / .'$1
3
+ .~ .~~~..~.
4
+ : .~.'~'.~. :
5
+ ~ ( ) ( ) ~
6
+ ( : '~'.~.'~' : )
7
+ ~ .~ ( ) ~. ~
8
+ ( : '~' : )
9
+ '~ .~~~. ~'
10
+ '~'
Binary file
Binary file