[autotest] inline cros_build_lib.IsInsideChroot usage
This func is a single os.path.exists check, so inline it to help
break the chromite dependency in these modules.
BUG=chromium:1049711
TEST=CQ passes
Change-Id: Iedaf79c29bbdb153cd5388ab409e0f68caa4d458
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2044536
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Alex Zamorzaev <zamorzaev@chromium.org>
diff --git a/server/site_utils.py b/server/site_utils.py
index 8cfbeae..219fd6e 100644
--- a/server/site_utils.py
+++ b/server/site_utils.py
@@ -614,24 +614,10 @@
def is_inside_chroot():
"""Check if the process is running inside chroot.
- This is a wrapper around chromite.lib.cros_build_lib.IsInsideChroot(). The
- method checks if cros_build_lib can be imported first.
-
- @return: True if the process is running inside chroot or cros_build_lib
- cannot be imported.
+ @return: True if the process is running inside chroot.
"""
- try:
- # TODO(crbug.com/739466) This module import is delayed because it adds
- # 1-2 seconds to the module import time and most users of site_utils
- # don't need it. The correct fix is to break apart site_utils into more
- # meaningful chunks.
- from chromite.lib import cros_build_lib
- except ImportError:
- logging.warn('Unable to import chromite. Can not detect chroot. '
- 'Defaulting to False')
- return False
- return cros_build_lib.IsInsideChroot()
+ return os.path.exists('/etc/cros_chroot_version')
def parse_job_name(name):