| OLD | NEW |
| 1 # Copyright (c) 2011 Google Inc. All rights reserved. | 1 # Copyright (c) 2011 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 raise AssertionError('unrecognized platform string "%s"' % sys_platform) | 131 raise AssertionError('unrecognized platform string "%s"' % sys_platform) |
| 132 | 132 |
| 133 def _determine_mac_version(self, mac_version_string): | 133 def _determine_mac_version(self, mac_version_string): |
| 134 release_version = int(mac_version_string.split('.')[1]) | 134 release_version = int(mac_version_string.split('.')[1]) |
| 135 version_strings = { | 135 version_strings = { |
| 136 5: 'leopard', | 136 5: 'leopard', |
| 137 6: 'snowleopard', | 137 6: 'snowleopard', |
| 138 7: 'lion', | 138 7: 'lion', |
| 139 8: 'mountainlion', | 139 8: 'mountainlion', |
| 140 9: 'mavericks', | 140 9: 'mavericks', |
| 141 10: 'yosemite', |
| 141 } | 142 } |
| 142 assert release_version >= min(version_strings.keys()) | 143 assert release_version >= min(version_strings.keys()) |
| 143 return version_strings.get(release_version, 'future') | 144 return version_strings.get(release_version, 'future') |
| 144 | 145 |
| 145 def _determine_linux_version(self): | 146 def _determine_linux_version(self): |
| 146 # FIXME: we ignore whatever the real version is and pretend it's lucid f
or now. | 147 # FIXME: we ignore whatever the real version is and pretend it's lucid f
or now. |
| 147 return 'lucid' | 148 return 'lucid' |
| 148 | 149 |
| 149 def _determine_win_version(self, win_version_tuple): | 150 def _determine_win_version(self, win_version_tuple): |
| 150 if win_version_tuple[:3] == (6, 1, 7600): | 151 if win_version_tuple[:3] == (6, 1, 7600): |
| 151 return '7sp0' | 152 return '7sp0' |
| 152 if win_version_tuple[:2] == (6, 0): | 153 if win_version_tuple[:2] == (6, 0): |
| 153 return 'vista' | 154 return 'vista' |
| 154 if win_version_tuple[:2] == (5, 1): | 155 if win_version_tuple[:2] == (5, 1): |
| 155 return 'xp' | 156 return 'xp' |
| 156 assert win_version_tuple[0] > 6 or win_version_tuple[1] >= 1, 'Unrecogni
zed Windows version tuple: "%s"' % (win_version_tuple,) | 157 assert win_version_tuple[0] > 6 or win_version_tuple[1] >= 1, 'Unrecogni
zed Windows version tuple: "%s"' % (win_version_tuple,) |
| 157 return 'future' | 158 return 'future' |
| 158 | 159 |
| 159 def _win_version_tuple(self, sys_module): | 160 def _win_version_tuple(self, sys_module): |
| 160 if hasattr(sys_module, 'getwindowsversion'): | 161 if hasattr(sys_module, 'getwindowsversion'): |
| 161 return sys_module.getwindowsversion() | 162 return sys_module.getwindowsversion() |
| 162 return self._win_version_tuple_from_cmd() | 163 return self._win_version_tuple_from_cmd() |
| 163 | 164 |
| 164 def _win_version_tuple_from_cmd(self): | 165 def _win_version_tuple_from_cmd(self): |
| 165 # Note that this should only ever be called on windows, so this should a
lways work. | 166 # Note that this should only ever be called on windows, so this should a
lways work. |
| 166 ver_output = self._executive.run_command(['cmd', '/c', 'ver'], decode_ou
tput=False) | 167 ver_output = self._executive.run_command(['cmd', '/c', 'ver'], decode_ou
tput=False) |
| 167 match_object = re.search(r'(?P<major>\d+)\.(?P<minor>\d)\.(?P<build>\d+)
', ver_output) | 168 match_object = re.search(r'(?P<major>\d+)\.(?P<minor>\d)\.(?P<build>\d+)
', ver_output) |
| 168 assert match_object, 'cmd returned an unexpected version string: ' + ver
_output | 169 assert match_object, 'cmd returned an unexpected version string: ' + ver
_output |
| 169 return tuple(map(int, match_object.groups())) | 170 return tuple(map(int, match_object.groups())) |
| OLD | NEW |