Avi Drissman | 73a09d1 | 2022-09-08 20:33:38 | [diff] [blame] | 1 | # Copyright 2013 The Chromium Authors |
[email protected] | ec069f7 | 2013-08-21 02:44:58 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
3 | # found in the LICENSE file. | ||||
4 | |||||
5 | |||||
[email protected] | ec069f7 | 2013-08-21 02:44:58 | [diff] [blame] | 6 | import sys |
7 | |||||
8 | |||||
[email protected] | ec069f7 | 2013-08-21 02:44:58 | [diff] [blame] | 9 | def IsWindows(): |
10 | return sys.platform in ['win32', 'cygwin'] | ||||
11 | |||||
12 | |||||
[email protected] | ec069f7 | 2013-08-21 02:44:58 | [diff] [blame] | 13 | def IsLinux(): |
krytarowski | ec291e214 | 2016-08-09 19:36:24 | [diff] [blame] | 14 | return sys.platform.startswith(('linux', 'freebsd', 'netbsd', 'openbsd')) |
[email protected] | ec069f7 | 2013-08-21 02:44:58 | [diff] [blame] | 15 | |
16 | |||||
[email protected] | ec069f7 | 2013-08-21 02:44:58 | [diff] [blame] | 17 | def IsMac(): |
18 | return sys.platform == 'darwin' | ||||
19 | |||||
20 | |||||
Michael Achenbach | d76f98f | 2018-02-16 22:40:01 | [diff] [blame] | 21 | def host_os(): |
22 | """ | ||||
23 | Returns a string representing the host_os of the current system. | ||||
24 | Possible values: 'win', 'mac', 'linux', 'unknown'. | ||||
25 | """ | ||||
26 | if IsWindows(): | ||||
27 | return 'win' | ||||
28 | elif IsLinux(): | ||||
29 | return 'linux' | ||||
30 | elif IsMac(): | ||||
31 | return 'mac' | ||||
32 | else: | ||||
33 | return 'unknown' |