[O] Global IS_WINDOWS constant
This commit is contained in:
parent
6f0e659d90
commit
96a48659e5
2 changed files with 7 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import platform
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ _/\_\_ _/_/\_
|
||||||
|
|
||||||
TEST_ASCII_WIDTH = max(len(line) for line in TEST_ASCII.split('\n'))
|
TEST_ASCII_WIDTH = max(len(line) for line in TEST_ASCII.split('\n'))
|
||||||
DEFAULT_DARK_L = 0.
|
DEFAULT_DARK_L = 0.
|
||||||
|
IS_WINDOWS = platform.system() == 'Windows'
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class GlobalConfig:
|
class GlobalConfig:
|
||||||
|
|
|
@ -4,10 +4,10 @@ import os
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import zipfile
|
import zipfile
|
||||||
import shutil
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
|
@ -16,13 +16,12 @@ from tempfile import TemporaryDirectory
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
from .color_util import color, printc
|
from .color_util import color, printc
|
||||||
from .constants import GLOBAL_CFG, MINGIT_URL
|
from .constants import GLOBAL_CFG, MINGIT_URL, IS_WINDOWS
|
||||||
from .distros import distro_detector
|
from .distros import distro_detector
|
||||||
from .presets import ColorProfile
|
from .presets import ColorProfile
|
||||||
from .serializer import from_dict
|
from .serializer import from_dict
|
||||||
from .types import BackendLiteral, ColorAlignMode
|
from .types import BackendLiteral, ColorAlignMode
|
||||||
|
|
||||||
|
|
||||||
RE_NEOFETCH_COLOR = re.compile('\\${c[0-9]}')
|
RE_NEOFETCH_COLOR = re.compile('\\${c[0-9]}')
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,7 +155,7 @@ def get_command_path() -> str:
|
||||||
cmd_path = pkg_resources.resource_filename(__name__, 'scripts/neowofetch')
|
cmd_path = pkg_resources.resource_filename(__name__, 'scripts/neowofetch')
|
||||||
|
|
||||||
# Windows doesn't support symbolic links, but also I can't detect symbolic links... hard-code it here for now.
|
# Windows doesn't support symbolic links, but also I can't detect symbolic links... hard-code it here for now.
|
||||||
if platform.system() == 'Windows':
|
if IS_WINDOWS:
|
||||||
pkg = Path(__file__).parent
|
pkg = Path(__file__).parent
|
||||||
pth = (shutil.which("neowofetch") or
|
pth = (shutil.which("neowofetch") or
|
||||||
if_file(cmd_path) or
|
if_file(cmd_path) or
|
||||||
|
@ -179,7 +178,7 @@ def ensure_git_bash() -> Path:
|
||||||
|
|
||||||
:returns git bash path
|
:returns git bash path
|
||||||
"""
|
"""
|
||||||
if platform.system() == 'Windows':
|
if IS_WINDOWS:
|
||||||
# Find installation in default path
|
# Find installation in default path
|
||||||
def_path = Path(r'C:\Program Files\Git\bin\bash.exe')
|
def_path = Path(r'C:\Program Files\Git\bin\bash.exe')
|
||||||
if def_path.is_file():
|
if def_path.is_file():
|
||||||
|
@ -223,7 +222,7 @@ def check_windows_cmd():
|
||||||
Check if this script is running under cmd.exe. If so, launch an external window with git bash
|
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.
|
since cmd doesn't support RGB colors.
|
||||||
"""
|
"""
|
||||||
if platform.system() == 'Windows':
|
if IS_WINDOWS:
|
||||||
import psutil
|
import psutil
|
||||||
# TODO: This line does not correctly identify cmd prompts...
|
# TODO: This line does not correctly identify cmd prompts...
|
||||||
if psutil.Process(os.getppid()).name().lower().strip() == 'cmd.exe':
|
if psutil.Process(os.getppid()).name().lower().strip() == 'cmd.exe':
|
||||||
|
|
Loading…
Reference in a new issue