From 901e02553ac163299825d25aaddab0a6c648d0e6 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 26 Apr 2013 20:55:57 -0400 Subject: [PATCH] swc-installation-test-2.py: Use ProgramFiles environment variable On Fri, Apr 26, 2013 at 11:45:12AM -0700, Onno Broekmans wrote: > ... the installation paths you mention are incorrect for the > majority of modern Windows 7 installations. These are 64-bit > installations, and they have a special folder for 32-bit programs: > "C:\Program Files (x86)". So Notepad++ can be found in: > > C:\Program Files (x86)\Notepad++\notepad++.exe > > In the script, you could just check for the program's existence > using both paths ("C:\Program Files" _and_ "C:\Program Files > (x86)"), or you could use the "ProgramFiles" environment variable. Environment variable it is! From the Microsoft docs [1]: CSIDL_PROGRAM_FILESX86 The Program Files folder on 64-bit systems. A typical path is C:\Program Files(86). ... CSIDL_PROGRAM_FILES Version 5.0. The Program Files folder. A typical path is C:\Program Files. ... PROGRAMFILES Same as CSIDL_PROGRAM_FILES. PROGRAMFILES(X86) Refers to the C:\Program Files (x86) folder on 64-bit systems. We're just looking for executables, so it would be ok if we found a 32-bit Notepad++ or a 64-bit Notepad++. With this commit, we check both locations (if there are two distinct locations). [1]: http://technet.microsoft.com/en-us/library/cc749104%28v=ws.10%29.aspx --- setup/swc-installation-test-2.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/setup/swc-installation-test-2.py b/setup/swc-installation-test-2.py index 3778d7f..c74c75d 100755 --- a/setup/swc-installation-test-2.py +++ b/setup/swc-installation-test-2.py @@ -483,6 +483,16 @@ class CommandDependency (Dependency): return match.group(1) +def _program_files_paths(*args): + "Utility for generating MS Windows search paths" + pf = _os.environ.get('ProgramFiles', '/usr/bin') + pfx86 = _os.environ.get('ProgramFiles(x86)', pf) + paths = [_os.path.join(pf, *args)] + if pfx86 != pf: + paths.append(_os.path.join(pfx86, *args)) + return paths + + for command,long_name,minimum_version,paths in [ ('sh', 'Bourne Shell', None, None), ('ash', 'Almquist Shell', None, None), @@ -506,19 +516,13 @@ for command,long_name,minimum_version,paths in [ ('nano', 'Nano', None, None), ('gedit', None, None, None), ('kate', 'Kate', None, None), - ('notepad++', 'Notepad++', None, [ - _os.path.join( - _ROOT_PATH, 'Program Files', 'Notepad++', 'notepad++.exe'), - ]), - ('firefox', 'Firefox', None, [ - _os.path.join( - _ROOT_PATH, 'Program Files', 'Mozilla Firefox', 'firefox.exe'), - ]), - ('google-chrome', 'Google Chrome', None, [ - _os.path.join( - _ROOT_PATH, 'Program Files', 'Google', 'Chrome', 'Application', - 'chrome.exe'), - ]), + ('notepad++', 'Notepad++', None, + _program_files_paths('Notepad++', 'notepad++.exe')), + ('firefox', 'Firefox', None, + _program_files_paths('Mozilla Firefox', 'firefox.exe')), + ('google-chrome', 'Google Chrome', None, + _program_files_paths('Google', 'Chrome', 'Application', 'chrome.exe') + ), ('chromium', 'Chromium', None, None), ]: if not long_name: -- 2.26.2