From 59fa4e5ecc74a91316e6c4f4960e8475c8a2d4a4 Mon Sep 17 00:00:00 2001 From: wuliaozhiji Date: Tue, 30 Aug 2022 19:27:41 -0400 Subject: [PATCH] [F] Fix windows paths --- hyfetch/main.py | 7 ++++++- hyfetch/neofetch_util.py | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hyfetch/main.py b/hyfetch/main.py index b3e04fcf..44e1ae87 100755 --- a/hyfetch/main.py +++ b/hyfetch/main.py @@ -6,6 +6,7 @@ import json import random import re from itertools import permutations +import traceback from typing import Iterable from math import ceil @@ -389,7 +390,11 @@ def run(): preset = preset.set_light_dl(config.lightness) # Run - run_neofetch(preset, config.color_align) + try: + run_neofetch(preset, config.color_align) + except Exception as e: + print(f'Error: {e}') + traceback.print_exc() if args.ask_exit: input('Press any key to exit...') diff --git a/hyfetch/neofetch_util.py b/hyfetch/neofetch_util.py index 51e57624..a742d684 100644 --- a/hyfetch/neofetch_util.py +++ b/hyfetch/neofetch_util.py @@ -6,6 +6,7 @@ import platform import re import shlex import subprocess +import sys import zipfile from dataclasses import dataclass from pathlib import Path @@ -145,7 +146,7 @@ def get_command_path() -> str: # Windows doesn't support symbolic links, but also I can't detect symbolic links... hard-code it here for now. if platform.system() == 'Windows': - return str(Path(cmd_path).parent.parent / 'neofetch') + return str(Path(cmd_path).parent.parent.parent / 'neofetch') return cmd_path @@ -192,11 +193,12 @@ def check_windows_cmd(): """ if platform.system() == 'Windows': import psutil + # TODO: This line does not correctly identify cmd prompts... 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() + sys.exit(0) def run_command(args: str, pipe: bool = False) -> str | None: