Fix potential error for sys.platform
This CL is to fix gap between python2.x and 3.x. For python2.x: sys.platform returns 'linux2' For python3.x: sys.platform returns 'linux' python3.x(https://docs.python.org/3.6/library/sys.html#sys.platform) python2.x(https://docs.python.org/2.7/library/sys.html#sys.platform) Both 2.x and 3.x recommend to use 'startswith' to identify sys.platform. Change-Id: Id5a0a007518b329d1320baf96ecf1164cd3ebec1 Signed-off-by: jiajia tang <tangjiajia@xiaomi.com>
This commit is contained in:
@@ -72,9 +72,9 @@ ELF = collections.namedtuple(
|
||||
|
||||
def _get_os_name():
|
||||
"""Get the host OS name."""
|
||||
if sys.platform == 'linux2':
|
||||
if sys.platform.startswith('linux'):
|
||||
return 'linux'
|
||||
if sys.platform == 'darwin':
|
||||
if sys.platform.startswith('darwin'):
|
||||
return 'darwin'
|
||||
raise ValueError(sys.platform + ' is not supported')
|
||||
|
||||
|
Reference in New Issue
Block a user