Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: Tools/Scripts/webkitpy/common/system/platforminfo.py

Issue 1201873002: Move LayoutTest Linux distribution detection to PlatformInfo (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove crusty comment Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 25 matching lines...) Expand all
36 to be used by the rest of the webkitpy code base. 36 to be used by the rest of the webkitpy code base.
37 37
38 Public (static) properties: 38 Public (static) properties:
39 -- os_name 39 -- os_name
40 -- os_version 40 -- os_version
41 41
42 Note that 'future' is returned for os_version if the operating system is 42 Note that 'future' is returned for os_version if the operating system is
43 newer than one known to the code. 43 newer than one known to the code.
44 """ 44 """
45 45
46 def __init__(self, sys_module, platform_module, executive): 46 def __init__(self, sys_module, platform_module, filesystem_module, executive ):
47 self._executive = executive 47 self._executive = executive
48 self._filesystem = filesystem_module
48 self._platform_module = platform_module 49 self._platform_module = platform_module
49 self.os_name = self._determine_os_name(sys_module.platform) 50 self.os_name = self._determine_os_name(sys_module.platform)
50 if self.os_name == 'linux': 51 if self.os_name == 'linux':
51 self.os_version = self._determine_linux_version() 52 self.os_version = self._determine_linux_version()
52 if self.os_name == 'freebsd': 53 if self.os_name == 'freebsd':
53 self.os_version = platform_module.release() 54 self.os_version = platform_module.release()
54 if self.os_name.startswith('mac'): 55 if self.os_name.startswith('mac'):
55 self.os_version = self._determine_mac_version(platform_module.mac_ve r()[0]) 56 self.os_version = self._determine_mac_version(platform_module.mac_ve r()[0])
56 if self.os_name.startswith('win'): 57 if self.os_name.startswith('win'):
57 self.os_version = self._determine_win_version(self._win_version_tupl e(sys_module)) 58 self.os_version = self._determine_win_version(self._win_version_tupl e(sys_module))
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 else: 113 else:
113 import fcntl 114 import fcntl
114 import struct 115 import struct
115 import termios 116 import termios
116 packed = fcntl.ioctl(sys.stderr.fileno(), termios.TIOCGWINSZ, '\ 0' * 8) 117 packed = fcntl.ioctl(sys.stderr.fileno(), termios.TIOCGWINSZ, '\ 0' * 8)
117 _, columns, _, _ = struct.unpack('HHHH', packed) 118 _, columns, _, _ = struct.unpack('HHHH', packed)
118 return columns 119 return columns
119 except: 120 except:
120 return sys.maxint 121 return sys.maxint
121 122
123 def linux_distribution(self):
124 if not self.is_linux():
125 return None
126
127 if self._filesystem.exists('/etc/redhat-release'):
128 return 'redhat'
129 if self._filesystem.exists('/etc/debian_version'):
130 return 'debian'
131 if self._filesystem.exists('/etc/arch-release'):
132 return 'arch'
133
134 return 'unknown'
135
122 def _determine_os_name(self, sys_platform): 136 def _determine_os_name(self, sys_platform):
123 if sys_platform == 'darwin': 137 if sys_platform == 'darwin':
124 return 'mac' 138 return 'mac'
125 if sys_platform.startswith('linux'): 139 if sys_platform.startswith('linux'):
126 return 'linux' 140 return 'linux'
127 if sys_platform in ('win32', 'cygwin'): 141 if sys_platform in ('win32', 'cygwin'):
128 return 'win' 142 return 'win'
129 if sys_platform.startswith('freebsd'): 143 if sys_platform.startswith('freebsd'):
130 return 'freebsd' 144 return 'freebsd'
131 raise AssertionError('unrecognized platform string "%s"' % sys_platform) 145 raise AssertionError('unrecognized platform string "%s"' % sys_platform)
(...skipping 29 matching lines...) Expand all
161 if hasattr(sys_module, 'getwindowsversion'): 175 if hasattr(sys_module, 'getwindowsversion'):
162 return sys_module.getwindowsversion() 176 return sys_module.getwindowsversion()
163 return self._win_version_tuple_from_cmd() 177 return self._win_version_tuple_from_cmd()
164 178
165 def _win_version_tuple_from_cmd(self): 179 def _win_version_tuple_from_cmd(self):
166 # Note that this should only ever be called on windows, so this should a lways work. 180 # Note that this should only ever be called on windows, so this should a lways work.
167 ver_output = self._executive.run_command(['cmd', '/c', 'ver'], decode_ou tput=False) 181 ver_output = self._executive.run_command(['cmd', '/c', 'ver'], decode_ou tput=False)
168 match_object = re.search(r'(?P<major>\d+)\.(?P<minor>\d)\.(?P<build>\d+) ', ver_output) 182 match_object = re.search(r'(?P<major>\d+)\.(?P<minor>\d)\.(?P<build>\d+) ', ver_output)
169 assert match_object, 'cmd returned an unexpected version string: ' + ver _output 183 assert match_object, 'cmd returned an unexpected version string: ' + ver _output
170 return tuple(map(int, match_object.groups())) 184 return tuple(map(int, match_object.groups()))
OLDNEW
« no previous file with comments | « LayoutTests/http/conf/redhat-httpd-2.4.conf ('k') | Tools/Scripts/webkitpy/common/system/platforminfo_mock.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698