From 71ab00a3c139055e2b2e762a05a52fa4a0e48e8f Mon Sep 17 00:00:00 2001 From: David Vo Date: Mon, 3 Jun 2024 00:38:09 +1000 Subject: [PATCH] Delete dead Windows-specific code (#1441) --- apps/wsl/wsl.py | 11 ++--------- core/app_switcher/app_switcher.py | 12 +----------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/apps/wsl/wsl.py b/apps/wsl/wsl.py index 301f188c2c..5cea9511a3 100644 --- a/apps/wsl/wsl.py +++ b/apps/wsl/wsl.py @@ -14,14 +14,13 @@ # note: this context match is intentionally made more complex so that it is more specific # than the context defined in apps/win/windows_terminal/windows_terminal.py (and thereby # takes precedence). -ctx.matches = rf""" +ctx.matches = """ app: windows_terminal and tag: user.wsl tag: user.wsl """ if app.platform == "windows": - import atexit import platform import win32api @@ -67,10 +66,6 @@ def _close_key(): win32api.RegCloseKey(registry_key_handle) registry_key_handle = None - # make sure registry is closed on exit - def atexit(): - _close_key() - # open the registry key containing the list of installed wsl distros def _initialize_key(): global key_event, registry_key_handle, registry_access_flags @@ -152,7 +147,7 @@ def _update_wsl_distros(): error = win32api.GetLastError() _close_key() raise Exception( - "failed while checking for wsl registry updates: {result=}: {error=}" + f"failed while checking for wsl registry updates: {result=}: {error=}" ) except OSError: if distro_handle: @@ -254,7 +249,6 @@ def _disable_path_detection(notify=True): def run_wslpath(args, in_path, in_distro=None): - global path_detection_disabled path = "" if not path_detection_disabled: @@ -420,7 +414,6 @@ def file_manager_open_parent(): actions.key("enter") def file_manager_current_path(): - global path_detection_disabled if path_detection_disabled: logging.warning( 'Skipping WSL path detection - try "weasel reset path detection"' diff --git a/core/app_switcher/app_switcher.py b/core/app_switcher/app_switcher.py index 5fe574256c..d3ca588da7 100644 --- a/core/app_switcher/app_switcher.py +++ b/core/app_switcher/app_switcher.py @@ -84,19 +84,9 @@ if app.platform == "windows": import ctypes import os - - import pywintypes - - try: - pass - except ImportError: - # Python 2 - pass - - bytes = lambda x: str(buffer(x)) - from ctypes import wintypes + import pywintypes from win32com.propsys import propsys, pscon from win32com.shell import shell, shellcon