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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 Arguments: | 57 Arguments: |
58 key: The registry key. | 58 key: The registry key. |
59 value: The particular registry value to read (optional). | 59 value: The particular registry value to read (optional). |
60 Return: | 60 Return: |
61 stdout from reg.exe, or None for failure. | 61 stdout from reg.exe, or None for failure. |
62 """ | 62 """ |
63 text = None | 63 text = None |
64 try: | 64 try: |
65 text = self._QueryBase('Sysnative', key, value) | 65 text = self._QueryBase('Sysnative', key, value) |
66 except OSError, e: | 66 except OSError as e: |
67 if e.errno == errno.ENOENT: | 67 if e.errno == errno.ENOENT: |
68 text = self._QueryBase('System32', key, value) | 68 text = self._QueryBase('System32', key, value) |
69 else: | 69 else: |
70 raise | 70 raise |
71 return text | 71 return text |
72 | 72 |
73 def GetValue(self, key, value): | 73 def GetValue(self, key, value): |
74 """Use reg.exe to obtain the value of a registry key. | 74 """Use reg.exe to obtain the value of a registry key. |
75 | 75 |
76 Args: | 76 Args: |
(...skipping 15 matching lines...) Expand all 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 |