tools/mac/power/driver.py
def CheckEnv(self, throw_on_bad_env):
    """Verifies that the environment is conducive to proper profiling or
    measurements.

    Args:
      throw_on_bad_env: False if executions continues no matter what and
      only warnings are printed.

    Raises:
      SystemExit: When the environment is invalid and throw_on_bad_env is
      True.
    """

    if throw_on_bad_env:
      logging_function = logging.error
    else:
      logging_function = logging.warning

    logging.warning("Trying sudo access. Possibly enter password:")
    sudo_check = subprocess.Popen(["sudo", "ls"],
            stdout=subprocess.DEVNULL,
            stderr=subprocess.STDOUT)
    sudo_check.wait()

    try:
      check_env = subprocess.run(['zsh', '-c', './check_env.sh'],
                                 check=throw_on_bad_env,
                                 capture_output=True)
      logging_function(check_env.stdout.decode('ascii'))
    except subprocess.CalledProcessError as e:
      logging_function(e.stdout.decode('ascii'))
      sys.exit(-1)

    # Make sure that no browsers are running which would affect the
    # tests.
    for browser in utils.get_browser_process_names():
      if self.FindBrowserProcess(browser):
        logging_function(f"{browser} already running. \
                Make sure to close it before running again.")

        if throw_on_bad_env:
          sys.exit(-1)
Verifies that the environment is conducive to proper profiling or
    measurements.

    Args:
      throw_on_bad_env: False if executions continues no matter what and
      only warnings are printed.

    Raises:
      SystemExit: When the environment is invalid and throw_on_bad_env is
      True.
    
Verifies that the environment is conducive to proper profiling or
measurements.

False if executions continues no matter what and
only warnings are printed.

When the environment is invalid and throw_on_bad_env is
True.
Verifies that the environment is conducive to proper profiling or measurements . False if executions continues no matter what and only warnings are printed . When the environment is invalid and throw_on_bad_env is True .
def CheckEnv(self, throw_on_bad_env):
    if throw_on_bad_env:
      logging_function = logging.error
    else:
      logging_function = logging.warning
    logging.warning("Trying sudo access. Possibly enter password:")
    sudo_check = subprocess.Popen(["sudo", "ls"],
            stdout=subprocess.DEVNULL,
            stderr=subprocess.STDOUT)
    sudo_check.wait()
    try:
      check_env = subprocess.run(['zsh', '-c', './check_env.sh'],
                                 check=throw_on_bad_env,
                                 capture_output=True)
      logging_function(check_env.stdout.decode('ascii'))
    except subprocess.CalledProcessError as e:
      logging_function(e.stdout.decode('ascii'))
      sys.exit(-1)
    for browser in utils.get_browser_process_names():
      if self.FindBrowserProcess(browser):
        logging_function(f"{browser} already running. \
                Make sure to close it before running again.")
        if throw_on_bad_env:
          sys.exit(-1)
def CheckEnv ( self , throw_on_bad_env ) : if throw_on_bad_env : logging_function = logging . error else : logging_function = logging . warning logging . warning ( "Trying sudo access. Possibly enter password:" ) sudo_check = subprocess . Popen ( [ "sudo" , "ls" ] , stdout = subprocess . DEVNULL , stderr = subprocess . STDOUT ) sudo_check . wait ( ) try : check_env = subprocess . run ( [ 'zsh' , '-c' , './check_env.sh' ] , check = throw_on_bad_env , capture_output = True ) logging_function ( check_env . stdout . decode ( 'ascii' ) ) except subprocess . CalledProcessError as e : logging_function ( e . stdout . decode ( 'ascii' ) ) sys . exit ( - 1 ) for browser in utils . get_browser_process_names ( ) : if self . FindBrowserProcess ( browser ) : logging_function ( f"{browser} already running. \
                Make sure to close it before running again." ) if throw_on_bad_env : sys . exit ( - 1 )
Verifies that the environment is conducive to proper profiling or
measurements.
Verifies that the environment is conducive to proper profiling or measurements .
"""Verifies that the environment is conducive to proper profiling or
    measurements.

    Args:
      throw_on_bad_env: False if executions continues no matter what and
      only warnings are printed.

    Raises:
      SystemExit: When the environment is invalid and throw_on_bad_env is
      True.
    """ # Make sure that no browsers are running which would affect the # tests.
self
throw_on_bad_env