Index: chrome/test/mini_installer/path_resolver.py |
diff --git a/chrome/test/mini_installer/path_resolver.py b/chrome/test/mini_installer/path_resolver.py |
index 27f2d1dda49ee716ad22770942be7eb7a248de53..db36a916dfa5d560374579ac7b2c508b8449344f 100644 |
--- a/chrome/test/mini_installer/path_resolver.py |
+++ b/chrome/test/mini_installer/path_resolver.py |
@@ -9,6 +9,25 @@ import win32com.client |
from win32com.shell import shell, shellcon |
+def GetProductName(file_path): |
+ """Returns the product name of the given file. |
+ |
+ Args: |
+ file_path: The absolute or relative path to the file. |
+ |
+ Returns: |
+ A string representing the product name of the file, or None if the product |
+ name was not found. |
+ """ |
+ language_and_codepage_pairs = win32api.GetFileVersionInfo( |
+ file_path, '\\VarFileInfo\\Translation') |
+ if not language_and_codepage_pairs: |
+ return None |
+ subblock = ('\\StringFileInfo\\%04x%04x\\ProductName' % |
robertshield
2013/08/29 19:01:07
nit: subblock -> product_name_entry
sukolsak
2013/08/30 02:59:29
Done.
|
+ language_and_codepage_pairs[0]) |
+ return win32api.GetFileVersionInfo(file_path, subblock) |
gab
2013/08/29 12:31:06
I find it weird to have to inspect the mini_instal
robertshield
2013/08/29 19:01:07
I actually kind of like the approach taken here in
|
+ |
+ |
def ResolvePath(path): |
"""Resolves variables in a file path, and returns the resolved path. |
@@ -41,19 +60,21 @@ def ResolvePath(path): |
mini_installer_path = os.path.abspath('mini_installer.exe') |
mini_installer_file_version = win32com.client.Dispatch( |
'Scripting.FileSystemObject').GetFileVersion(mini_installer_path) |
- # TODO(sukolsak): Check whether this is Chrome or Chromium. |
- is_chrome = True |
- if is_chrome: |
+ mini_installer_product_name = GetProductName(mini_installer_path) |
+ if mini_installer_product_name == 'Google Chrome': |
chrome_short_name = 'Chrome' |
chrome_long_name = 'Google Chrome' |
chrome_dir = 'Google\\Chrome' |
chrome_update_registry_subkey = ('Software\\Google\\Update\\Clients\\' |
'{8A69D345-D564-463c-AFF1-A69D9E530F96}') |
- else: |
+ elif mini_installer_product_name == 'Chromium': |
chrome_short_name = 'Chromium' |
chrome_long_name = 'Chromium' |
chrome_dir = 'Chromium' |
chrome_update_registry_subkey = 'Software\\Chromium' |
+ else: |
+ raise KeyError("Unknown mini_installer's product name '%s'" % |
grt (UTC plus 2)
2013/08/30 02:39:59
nit: "mini_installer's" -> "mini_installer"
sukolsak
2013/08/30 02:59:29
Done.
|
+ mini_installer_product_name) |
robertshield
2013/08/29 19:01:07
This has the side benefit of breaking if mini_inst
|
variable_mapping = { |
'PROGRAM_FILES': program_files_path, |