[autotest] Prevent making gsutil call when running suite_scheduler.py  --sanity

"suite_scheduler.py --sanity" command is called in pre-submit hook to validate
the format of suite_scheduler.ini. The dependency of gsutil causes repo upload
failure if gsutil is not installed. This CL removes such dependency.

BUG=chromium:450689
TEST=uninstall gsutil, run "suite_scheduler.py --sanity", confirm the test
passes. Run "suite_scheduler.py", confirm the script failed as gsutil is not
found.

"suite_scheduler --sanity command check

Change-Id: I5db91d60a52d425e712a7f9a55ea1f4262b3c8f7
Reviewed-on: https://chromium-review.googlesource.com/242651
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Fang Deng <fdeng@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
diff --git a/site_utils/suite_scheduler/task.py b/site_utils/suite_scheduler/task.py
index fb6ef9f..a4a54d3 100644
--- a/site_utils/suite_scheduler/task.py
+++ b/site_utils/suite_scheduler/task.py
@@ -14,7 +14,6 @@
 import common
 from autotest_lib.server.cros.dynamic_suite import constants
 from autotest_lib.scheduler import scheduler_lib
-from autotest_lib.server import site_utils
 
 
 class MalformedConfigEntry(Exception):
@@ -47,6 +46,12 @@
 
     __metaclass__ = scheduler_lib.Singleton
 
+    # True if suite_scheduler is running for sanity check. When it's set to
+    # True, the code won't make gsutil call to get the actual tot milestone to
+    # avoid dependency on the installation of gsutil to run sanity check.
+    is_sanity = False
+
+
     @staticmethod
     def _tot_milestone():
         """Get the tot milestone, eg: R40
@@ -55,6 +60,11 @@
             the LATEST_BUILD_URL, or an empty string if LATEST_BUILD_URL
             doesn't exist.
         """
+        if TotMilestoneManager.is_sanity:
+            logging.info('suite_scheduler is running for sanity purpose, no '
+                         'need to get the actual tot milestone string.')
+            return 'R40'
+
         cmd = ['gsutil', 'cat', constants.LATEST_BUILD_URL]
         proc = subprocess.Popen(
                 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)