From e5d750e9b8f7fc6a4172932056eddeb3fc892e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Marqu=C3=A9s?= Date: Wed, 21 Dec 2022 06:53:04 -0300 Subject: [PATCH] Fix the way extensions are treated while finding executables in WIN32 (#2493) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the `find_executable()` function we split the extension of the file name passed from the base of the file name. In the case of WIN32, patroni will append a `.exe` if the current extension is not `.exe`. This brings the wrong behavior given that `more` in WIN32 is `more.com` and not `more.exe`. This also makes the pager setting from `ctl.py` fail as the code changes `more.com` (hardcoded in `ctl.py`) for `more.com.exe`. This change adjusts the behavior only to add the `.exe` if the executable variable doesn't have an extension. A better solution would be to *not* modify the name of the executable that is being passed, as that is what we are looking for. But that might have other consequences, so it would require further testing. Signed-off-by: Martín Marqués --- patroni/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patroni/utils.py b/patroni/utils.py index 01953d05..1c9ed554 100644 --- a/patroni/utils.py +++ b/patroni/utils.py @@ -519,8 +519,8 @@ def enable_keepalive(sock, timeout, idle, cnt=3): def find_executable(executable, path=None): _, ext = os.path.splitext(executable) - if (sys.platform == 'win32') and (ext != '.exe'): - executable = executable + '.exe' + if (sys.platform == 'win32') and (ext == ''): + executable = executable + '.exe' # Set default WIN extension if os.path.isfile(executable): return executable