Skip to content

Commit

Permalink
swc-installation-test-2.py: Use ProgramFiles environment variable
Browse files Browse the repository at this point in the history
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
  • Loading branch information
W. Trevor King committed Apr 27, 2013
1 parent 03b86fc commit 901e025
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions setup/swc-installation-test-2.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,16 @@ def _get_version(self):
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),
Expand All @@ -506,19 +516,13 @@ def _get_version(self):
('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:
Expand Down

0 comments on commit 901e025

Please sign in to comment.