[F] Make psutil dependency Windows-only

This commit is contained in:
Azalea (on HyDEV-Daisy) 2022-08-30 18:34:30 -04:00
parent 1456660797
commit a8352d1fef
No known key found for this signature in database
GPG key ID: E289FAC0DA92DD2B
2 changed files with 14 additions and 7 deletions

View file

@ -14,7 +14,6 @@ from tempfile import TemporaryDirectory
from urllib.request import urlretrieve
import pkg_resources
import psutil
from typing_extensions import Literal
from hyfetch.color_util import color
@ -185,11 +184,13 @@ def check_windows_cmd():
Check if this script is running under cmd.exe. If so, launch an external window with git bash
since cmd doesn't support RGB colors.
"""
if psutil.Process(os.getppid()).name().lower().strip() == 'cmd.exe':
print("cmd.exe doesn't support RGB colors, restarting in MinTTY...")
cmd = f'"{ensure_git_bash().parent.parent / "usr/bin/mintty.exe"}" -s 110,40 -e python -m hyfetch --ask-exit'
os.system(cmd)
exit()
if platform.system() == 'Windows':
import psutil
if psutil.Process(os.getppid()).name().lower().strip() == 'cmd.exe':
print("cmd.exe doesn't support RGB colors, restarting in MinTTY...")
cmd = f'"{ensure_git_bash().parent.parent / "usr/bin/mintty.exe"}" -s 110,40 -e python -m hyfetch --ask-exit'
os.system(cmd)
exit()
def run_command(args: str, pipe: bool = False) -> str | None: