mirror of
https://github.com/unixtensor/proxmox-ntfy.git
synced 2025-06-28 08:28:05 +00:00
16 lines
511 B
Python
16 lines
511 B
Python
import subprocess
|
|
|
|
from typing import Optional
|
|
|
|
def package_installed(package_name: str) -> Optional[bool]:
|
|
try:
|
|
installed = subprocess.run(["dpkg", "-s", package_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE).returncode == 0
|
|
if not installed:
|
|
print(f"Package \"{package_name}\" not installed.")
|
|
return installed
|
|
except Exception as err:
|
|
print(f"\033[31m{err}\033[0m")
|
|
return None
|
|
|
|
def uname() -> str:
|
|
return subprocess.run(["uname", "-a"], capture_output=True, text=True).stdout.strip() |