Skip to content

Commit

Permalink
Add default libraries with shutil during startup
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user authored Jan 4, 2025
1 parent e48ec55 commit 5e3761c
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions pyarchitecture/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import platform
import shutil

try:
from enum import StrEnum
Expand Down Expand Up @@ -38,32 +39,34 @@ class OperatingSystem(StrEnum):
def default_mem_lib():
"""Returns the default memory library dedicated to linux and macOS."""
return dict(
linux="/proc/meminfo", darwin="/usr/sbin/sysctl", windows="" # placeholder
linux="/proc/meminfo",
darwin=shutil.which("sysctl") or "/usr/sbin/sysctl",
windows="", # placeholder
)


def default_disk_lib():
"""Returns the default disks' library dedicated to each supported operating system."""
return dict(
linux="/usr/bin/lsblk",
darwin="/usr/sbin/diskutil",
windows="C:\\Program Files\\PowerShell\\7\\pwsh.exe",
linux=shutil.which("lsblk") or "/usr/bin/lsblk",
darwin=shutil.which("diskutil") or "/usr/sbin/diskutil",
windows=shutil.which("pwsh") or "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
)


def default_cpu_lib():
"""Returns the default processor library dedicated to each supported operating system."""
return dict(
linux="/proc/cpuinfo",
darwin="/usr/sbin/sysctl",
windows="C:\\Windows\\System32\\wbem\\wmic.exe",
darwin=shutil.which("sysctl") or "/usr/sbin/sysctl",
windows=shutil.which("wmic") or "C:\\Windows\\System32\\wbem\\wmic.exe",
)


def default_gpu_lib():
"""Returns the default GPU library dedicated to each supported operating system."""
return dict(
linux="/usr/bin/lspci",
darwin="/usr/sbin/system_profiler",
windows="C:\\Windows\\System32\\wbem\\wmic.exe",
linux=shutil.which("lspci") or "/usr/bin/lspci",
darwin=shutil.which("system_profiler") or "/usr/sbin/system_profiler",
windows=shutil.which("wmic") or "C:\\Windows\\System32\\wbem\\wmic.exe",
)

0 comments on commit 5e3761c

Please sign in to comment.