[autotest] Use the metrics_mock object in case chromite is not set up.
BUG=chromium:688166
TEST=unittest
Change-Id: Ic0077cb2dba75a8d820f229060f3f70f507850a1
Reviewed-on: https://chromium-review.googlesource.com/438754
Commit-Ready: Dan Shi <dshi@google.com>
Tested-by: Dan Shi <dshi@google.com>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/site_utils/count_jobs.py b/site_utils/count_jobs.py
index 19d61fb..6fe9056 100755
--- a/site_utils/count_jobs.py
+++ b/site_utils/count_jobs.py
@@ -14,7 +14,12 @@
from autotest_lib.frontend import setup_django_environment
from autotest_lib.frontend.afe import models
from autotest_lib.server import site_utils
-from chromite.lib import metrics
+
+try:
+ from chromite.lib import metrics
+except ImportError:
+ metrics = site_utils.metrics_mock
+
def number_of_jobs_since(delta):
"""Returns the number of jobs kicked off in the last |duration| minutes.