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

Side by Side Diff: testing/legion/task_controller.py

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Defines the task controller library.""" 5 """Defines the task controller library."""
6 6
7 import argparse 7 import argparse
8 import datetime 8 import datetime
9 import logging 9 import logging
10 import os 10 import os
11 import socket 11 import socket
12 import subprocess 12 import subprocess
13 import sys 13 import sys
14 import tempfile 14 import tempfile
15 import threading 15 import threading
16 import xmlrpclib 16 import xmlrpclib
17 17
18 #pylint: disable=relative-import 18 #pylint: disable=relative-import
19 import common_lib 19 import common_lib
20 import process
20 21
21 ISOLATE_PY = os.path.join(common_lib.SWARMING_DIR, 'isolate.py') 22 ISOLATE_PY = os.path.join(common_lib.SWARMING_DIR, 'isolate.py')
22 SWARMING_PY = os.path.join(common_lib.SWARMING_DIR, 'swarming.py') 23 SWARMING_PY = os.path.join(common_lib.SWARMING_DIR, 'swarming.py')
23 24
24 25
25 class Error(Exception): 26 class Error(Exception):
26 pass 27 pass
27 28
28 29
29 class ConnectionTimeoutError(Error): 30 class ConnectionTimeoutError(Error):
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 assert isinstance(level, (str, int)) 119 assert isinstance(level, (str, int))
119 if isinstance(level, int): 120 if isinstance(level, int):
120 level = logging.getLevelName(level) 121 level = logging.getLevelName(level)
121 self._verbosity = level #pylint: disable=attribute-defined-outside-init 122 self._verbosity = level #pylint: disable=attribute-defined-outside-init
122 123
123 @classmethod 124 @classmethod
124 def ReleaseAllTasks(cls): 125 def ReleaseAllTasks(cls):
125 for task in cls._tasks: 126 for task in cls._tasks:
126 task.Release() 127 task.Release()
127 128
129 def Process(self, cmd, verbose=False, detached=False, cwd=None):
130 return process.ControllerProcessWrapper(
131 self.rpc, cmd, verbose, detached, cwd)
132
128 def _CreateOTP(self): 133 def _CreateOTP(self):
129 """Creates the OTP.""" 134 """Creates the OTP."""
130 controller_name = socket.gethostname() 135 controller_name = socket.gethostname()
131 test_name = os.path.basename(sys.argv[0]) 136 test_name = os.path.basename(sys.argv[0])
132 creation_time = datetime.datetime.utcnow() 137 creation_time = datetime.datetime.utcnow()
133 otp = 'task:%s controller:%s test:%s creation:%s' % ( 138 otp = 'task:%s controller:%s test:%s creation:%s' % (
134 self._name, controller_name, test_name, creation_time) 139 self._name, controller_name, test_name, creation_time)
135 return otp 140 return otp
136 141
137 def Create(self): 142 def Create(self):
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 if p.returncode != 0: 204 if p.returncode != 0:
200 raise Error(stderr) 205 raise Error(stderr)
201 206
202 def OnConnect(self, ip_address): 207 def OnConnect(self, ip_address):
203 """Receives task ip address on connection.""" 208 """Receives task ip address on connection."""
204 self._ip_address = ip_address 209 self._ip_address = ip_address
205 self._connected = True 210 self._connected = True
206 self._rpc = common_lib.ConnectToServer(self._ip_address) 211 self._rpc = common_lib.ConnectToServer(self._ip_address)
207 logging.info('%s connected from %s', self._name, ip_address) 212 logging.info('%s connected from %s', self._name, ip_address)
208 self._connect_event.set() 213 self._connect_event.set()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698