[portability] Support unknown operating systems in gclient.

Detect the name of unknown operating systems using uname, if available,
since it doesn't append the operating system version.

Change-Id: Idab7bd0db65a8d424ec2fd48f06247405b6649e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4169240
Auto-Submit: Jonas Termansen <sortie@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
This commit is contained in:
Jonas Termansen
2023-01-19 17:56:40 +00:00
committed by LUCI CQ
parent faf64f1f63
commit bf7eb5292c
4 changed files with 16 additions and 7 deletions

View File

@@ -634,7 +634,7 @@ def CheckCallAndFilter(args, print_stdout=False, filter_fn=None,
# If our stdout is a terminal, then pass in a psuedo-tty pipe to our
# subprocess when filtering its output. This makes the subproc believe
# it was launched from a terminal, which will preserve ANSI color codes.
os_type = GetMacWinAixOrLinux()
os_type = GetOperatingSystem()
if sys.stdout.isatty() and os_type != 'win' and os_type != 'aix':
pipe_reader, pipe_writer = os.openpty()
else:
@@ -780,8 +780,8 @@ def FindFileUpwards(filename, path=None):
path = new_path
def GetMacWinAixOrLinux():
"""Returns 'mac', 'win', or 'linux', matching the current platform."""
def GetOperatingSystem():
"""Returns 'mac', 'win', 'linux', or the name of the current platform."""
if sys.platform.startswith(('cygwin', 'win')):
return 'win'
@@ -794,7 +794,10 @@ def GetMacWinAixOrLinux():
if sys.platform.startswith('aix'):
return 'aix'
raise Error('Unknown platform: ' + sys.platform)
try:
return os.uname().sysname.lower()
except AttributeError:
return sys.platform
def GetGClientRootAndEntries(path=None):