OLD | NEW |
1 # Copyright (c) 2014 Google Inc. All rights reserved. | 1 # Copyright (c) 2014 Google Inc. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """ | 5 """ |
6 TestWin.py: a collection of helpers for testing on Windows. | 6 TestWin.py: a collection of helpers for testing on Windows. |
7 """ | 7 """ |
8 | 8 |
9 import errno | 9 import errno |
10 import os | 10 import os |
(...skipping 26 matching lines...) Expand all Loading... |
37 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 37 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
38 # Get the stdout from reg.exe, reading to the end so p.returncode is valid | 38 # Get the stdout from reg.exe, reading to the end so p.returncode is valid |
39 # Note that the error text may be in [1] in some cases | 39 # Note that the error text may be in [1] in some cases |
40 text = p.communicate()[0] | 40 text = p.communicate()[0] |
41 # Check return code from reg.exe; officially 0==success and 1==error | 41 # Check return code from reg.exe; officially 0==success and 1==error |
42 if p.returncode: | 42 if p.returncode: |
43 return None | 43 return None |
44 return text | 44 return text |
45 | 45 |
46 def Query(self, key, value=None): | 46 def Query(self, key, value=None): |
47 """Use reg.exe to read a particular key through _QueryBase. | 47 r"""Use reg.exe to read a particular key through _QueryBase. |
48 | 48 |
49 First tries to launch from %WinDir%\Sysnative to avoid WoW64 redirection. If | 49 First tries to launch from %WinDir%\Sysnative to avoid WoW64 redirection. If |
50 that fails, it falls back to System32. Sysnative is available on Vista and | 50 that fails, it falls back to System32. Sysnative is available on Vista and |
51 up and available on Windows Server 2003 and XP through KB patch 942589. Note | 51 up and available on Windows Server 2003 and XP through KB patch 942589. Note |
52 that Sysnative will always fail if using 64-bit python due to it being a | 52 that Sysnative will always fail if using 64-bit python due to it being a |
53 virtual directory and System32 will work correctly in the first place. | 53 virtual directory and System32 will work correctly in the first place. |
54 | 54 |
55 KB 942589 - http://support.microsoft.com/kb/942589/en-us. | 55 KB 942589 - http://support.microsoft.com/kb/942589/en-us. |
56 | 56 |
57 Arguments: | 57 Arguments: |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 """Use reg.exe to see if a key exists. | 92 """Use reg.exe to see if a key exists. |
93 | 93 |
94 Args: | 94 Args: |
95 key: The registry key to check. | 95 key: The registry key to check. |
96 Return: | 96 Return: |
97 True if the key exists | 97 True if the key exists |
98 """ | 98 """ |
99 if not self.Query(key): | 99 if not self.Query(key): |
100 return False | 100 return False |
101 return True | 101 return True |
OLD | NEW |