tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

gs_util_wrapper.py (1087B)


      1 # Copyright 2024 The Chromium Authors
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 """ A simple wrapper of running gsutil.py from the depot_tools; all the
      5 functions in this module are running in a separated process. """
      6 
      7 import os
      8 import subprocess
      9 import sys
     10 
     11 from typing import List
     12 
     13 from common import DIR_SRC_ROOT
     14 
     15 
     16 def _find_gsutil() -> str:
     17    """ Returns the location of the gsutil.py. """
     18    sys.path.append(os.path.join(DIR_SRC_ROOT, 'build'))
     19    # Do not pollute the environment, callers should not use find_depot_tools
     20    # directly.
     21    # pylint: disable=import-error, import-outside-toplevel
     22    import find_depot_tools
     23    # pylint: enable=import-error, import-outside-toplevel
     24    sys.path.pop()
     25    return os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'gsutil.py')
     26 
     27 
     28 GSUTIL_PATH = _find_gsutil()
     29 
     30 
     31 def run_gsutil(args: List[str]) -> None:
     32    """ Runs gsutil with |args| and throws CalledProcessError if the process
     33    failed. """
     34    return subprocess.run([sys.executable, GSUTIL_PATH] + args, check=True)