()
return os_version
Retrieve the current OS version from machine.

  Returns:
    os_version: string, like '10.9.5' or '10.10'.
  Raises:
    GmacpyutilException: command failed to execute.
    GmacpyutilException: os_version does not match expected formatting.
Retrieve the current OS version from machine.
Retrieve the current OS version from machine .
def GetOSVersion():
  """Retrieve the current OS version from machine.

  Returns:
    os_version: string, like '10.9.5' or '10.10'.
  Raises:
    GmacpyutilException: command failed to execute.
    GmacpyutilException: os_version does not match expected formatting.
  """
  cmd = ['sw_vers', '-productVersion']
  out, err, rc = RunProcess(cmd)  # pylint: disable=unpacking-non-sequence
  if rc != 0:
    raise GmacpyutilException('Unable to retrieve OS version - Error: %s.', err)
  os_version = out.strip()
  match = re.match(r'([0-9]+\.)', os_version)
  if not match:
    raise GmacpyutilException('Unexpected OS version returned.')
  return os_version
def GetOSVersion ( ) : cmd = [ 'sw_vers' , '-productVersion' ] out , err , rc = RunProcess ( cmd ) # pylint: disable=unpacking-non-sequence if rc != 0 : raise GmacpyutilException ( 'Unable to retrieve OS version - Error: %s.' , err ) os_version = out . strip ( ) match = re . match ( r'([0-9]+\.)' , os_version ) if not match : raise GmacpyutilException ( 'Unexpected OS version returned.' ) return os_version