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

Unified Diff: testing/legion/host_controller.py

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « testing/legion/examples/subprocess/task.isolate ('k') | testing/legion/legion.isolate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/legion/host_controller.py
diff --git a/testing/legion/host_controller.py b/testing/legion/host_controller.py
new file mode 100644
index 0000000000000000000000000000000000000000..dadcba45b4bc4c157729c21102ea747becb3c399
--- /dev/null
+++ b/testing/legion/host_controller.py
@@ -0,0 +1,70 @@
+# Copyright 2015 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.
+
+"""Defines the host controller base library.
+
+This module is the basis on which host controllers are built and executed.
+"""
+
+import logging
+import sys
+
+#pylint: disable=relative-import
+import client_lib
+import common_lib
+import discovery_server
+
+
+class HostController(object):
+ """The base host controller class."""
+
+ def __init__(self):
+ self._discovery_server = discovery_server.DiscoveryServer()
+
+ def SetUp(self):
+ """Setup method used by the subclass."""
+ pass
+
+ def Task(self):
+ """Main task method used by the subclass."""
+ pass
+
+ def TearDown(self):
+ """Teardown method used by the subclass."""
+ pass
+
+ def NewClient(self, *args, **kwargs):
+ controller = client_lib.ClientController(*args, **kwargs)
+ self._discovery_server.RegisterClientCallback(
+ controller.otp, controller.OnConnect)
+ return controller
+
+ def RunController(self):
+ """Main entry point for the controller."""
+ print ' '.join(sys.argv)
+ common_lib.InitLogging()
+ self._discovery_server.Start()
+
+ error = None
+ tb = None
+ try:
+ self.SetUp()
+ self.Task()
+ except Exception as e:
+ # Defer raising exceptions until after TearDown and _TearDown are called.
+ error = e
+ tb = sys.exc_info()[-1]
+ try:
+ self.TearDown()
+ except Exception as e:
+ # Defer raising exceptions until after _TearDown is called.
+ # Note that an error raised here will obscure any errors raised
+ # previously.
+ error = e
+ tb = sys.exc_info()[-1]
+
+ self._discovery_server.Shutdown()
+ client_lib.ClientController.ReleaseAllControllers()
+ if error:
+ raise error, None, tb #pylint: disable=raising-bad-type
« no previous file with comments | « testing/legion/examples/subprocess/task.isolate ('k') | testing/legion/legion.isolate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698