Invoke update.py as a subprocess in coverage.py

Currently coverage.py is using update.py as a module which is not guaranteed

Bug: 1075586
Change-Id: Ia4c54413bfd63adc412fd665af26ac0b228f3e30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2210175
Auto-Submit: Prakhar Asthana <[email protected]>
Commit-Queue: Yuke Liao <[email protected]>
Reviewed-by: Yuke Liao <[email protected]>
Cr-Commit-Position: refs/heads/master@{#771111}
diff --git a/tools/code_coverage/coverage.py b/tools/code_coverage/coverage.py
index a4b8f88c..c190f33 100755
--- a/tools/code_coverage/coverage.py
+++ b/tools/code_coverage/coverage.py
@@ -157,7 +157,8 @@
     LLVM_COV_PATH = os.path.join(llvm_bin_dir, 'llvm-cov')
     LLVM_PROFDATA_PATH = os.path.join(llvm_bin_dir, 'llvm-profdata')
   else:
-    update.UpdatePackage('coverage_tools', coverage_utils.GetHostPlatform())
+    subprocess.check_call(
+        ['tools/clang/scripts/update.py', '--package', 'coverage_tools'])
 
   if coverage_utils.GetHostPlatform() == 'win':
     LLVM_COV_PATH += '.exe'
@@ -948,12 +949,6 @@
 
 def Main():
   """Execute tool commands."""
-  # Setup coverage binaries even when script is called with empty params. This
-  # is used by coverage bot for initial setup.
-  if len(sys.argv) == 1:
-    update.UpdatePackage('coverage_tools', coverage_utils.GetHostPlatform())
-    print(__doc__)
-    return
 
   # Change directory to source root to aid in relative paths calculations.
   global SRC_ROOT_PATH
@@ -961,6 +956,14 @@
       os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir))
   os.chdir(SRC_ROOT_PATH)
 
+  # Setup coverage binaries even when script is called with empty params. This
+  # is used by coverage bot for initial setup.
+  if len(sys.argv) == 1:
+    subprocess.check_call(
+        ['tools/clang/scripts/update.py', '--package', 'coverage_tools'])
+    print(__doc__)
+    return
+
   args = _ParseCommandArguments()
   coverage_utils.ConfigureLogging(verbose=args.verbose, log_file=args.log_file)
   _ConfigureLLVMCoverageTools(args)