Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: infra/scripts/legacy/scripts/slave/bootstrap.py

Issue 1213433006: Fork runtest.py and everything it needs src-side for easier hacking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: runisolatedtest.py Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: infra/scripts/legacy/scripts/slave/bootstrap.py
diff --git a/infra/scripts/legacy/scripts/slave/bootstrap.py b/infra/scripts/legacy/scripts/slave/bootstrap.py
new file mode 100644
index 0000000000000000000000000000000000000000..2bfa4cede28ef8ca648099128f9d4bb6f14509e8
--- /dev/null
+++ b/infra/scripts/legacy/scripts/slave/bootstrap.py
@@ -0,0 +1,47 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Utilities to enable slaves to determine their master without importing any
+buildbot or twisted code.
+"""
+
+import inspect
+import os
+import sys
+
+from common import chromium_utils
+import config_bootstrap
+
+
+def ImportMasterConfigs(master_name=None, include_internal=True):
+ """Imports master configs.
+
+ Normally a slave can use chromium_utils.GetActiveMaster() to find
+ itself and determine which ActiveMaster to use. In that case, the
+ active master name is passed in as an arg, and we only load the
+ site_config.py that defines it. When testing, the current "slave"
+ won't be found. In that case, we don't know which config to use, so
+ load them all. In either case, masters are assigned as attributes
+ to the config.Master object.
+ """
+ for master in chromium_utils.ListMasters(include_internal=include_internal):
+ path = os.path.join(master, 'master_site_config.py')
+ if os.path.exists(path):
+ local_vars = {}
+ try:
+ execfile(path, local_vars)
+ # pylint: disable=W0703
+ except Exception, e:
+ # Naked exceptions are banned by the style guide but we are
+ # trying to be resilient here.
+ print >> sys.stderr, 'WARNING: cannot exec ' + path
+ print >> sys.stderr, e
+ for (symbol_name, symbol) in local_vars.iteritems():
+ if inspect.isclass(symbol):
+ setattr(symbol, 'local_config_path', master)
+ setattr(config_bootstrap.Master, symbol_name, symbol)
+ # If we have a master_name and it matches, set
+ # config_bootstrap.Master.active_master.
+ if master_name and master_name == symbol_name:
+ setattr(config_bootstrap.Master, 'active_master', symbol)
« no previous file with comments | « infra/scripts/legacy/scripts/slave/annotation_utils.py ('k') | infra/scripts/legacy/scripts/slave/build_directory.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698