[autotest] suite-scheduler sanity check should not rely on django
Resubmit of CL:288396
This reverts commit babd70ccd5866fe5eb875e9c725a129d3c881c2c.
It also contains a fix for importing django.
TEST=Test on a ganeti
/usr/local/autotest/site_utils/suite_scheduler/suite_scheduler.py -b -d
/usr/local/autotest/logs -f /usr/local/autotest/suite_scheduler.ini
TEST=Test on a geneti
/usr/local/autotest/site_utils/suite_scheduler/suite_scheduler.py --sanity
(remove site-packages)
BUG=chromium:474671
Change-Id: I155750de1d05b6e3f2625a4ae210622f748975f7
Reviewed-on: https://chromium-review.googlesource.com/290251
Tested-by: Fang Deng <fdeng@chromium.org>
Reviewed-by: Dan Shi <dshi@chromium.org>
Commit-Queue: Fang Deng <fdeng@chromium.org>
diff --git a/server/site_utils.py b/server/site_utils.py
index 0f6e303..a0df249 100644
--- a/server/site_utils.py
+++ b/server/site_utils.py
@@ -49,6 +49,18 @@
pass
+class Singleton(type):
+ """Enforce that only one client class is instantiated per process."""
+ _instances = {}
+
+ def __call__(cls, *args, **kwargs):
+ """Fetch the instance of a class to use for subsequent calls."""
+ if cls not in cls._instances:
+ cls._instances[cls] = super(Singleton, cls).__call__(
+ *args, **kwargs)
+ return cls._instances[cls]
+
+
def ParseBuildName(name):
"""Format a build name, given board, type, milestone, and manifest num.