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

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

Issue 935333002: Update from https://crrev.com/316786 (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 unified diff | Download patch
« no previous file with comments | « testing/legion/client_rpc_methods.py ('k') | testing/legion/examples/hello_world/host_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 """Common library methods used by both host and client controllers.""" 5 """Common library methods used by both host and client controllers."""
6 6
7 import argparse 7 import argparse
8 import logging 8 import logging
9 import os
9 import socket 10 import socket
10 import xmlrpclib 11 import xmlrpclib
11 12
12 LOGGING_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'WARN', 'ERROR'] 13 LOGGING_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'WARN', 'ERROR']
13 MY_IP = socket.gethostbyname(socket.gethostname()) 14 MY_IP = socket.gethostbyname(socket.gethostname())
14 SERVER_ADDRESS = '' 15 SERVER_ADDRESS = ''
15 SERVER_PORT = 31710 16 SERVER_PORT = 31710
16 DEFAULT_TIMEOUT_SECS = 20 * 60 # 30 minutes 17 DEFAULT_TIMEOUT_SECS = 20 * 60 # 30 minutes
18 THIS_DIR = os.path.dirname(os.path.abspath(__file__))
19 SWARMING_DIR = os.path.join(THIS_DIR, '..', '..', 'tools', 'swarming_client')
17 20
18 21
19 def InitLogging(): 22 def InitLogging():
20 """Initialize the logging module. 23 """Initialize the logging module.
21 24
22 Raises: 25 Raises:
23 argparse.ArgumentError if the --verbosity arg is incorrect. 26 argparse.ArgumentError if the --verbosity arg is incorrect.
24 """ 27 """
25 parser = argparse.ArgumentParser() 28 parser = argparse.ArgumentParser()
26 logging_action = parser.add_argument('--verbosity', default='ERROR') 29 logging_action = parser.add_argument('--verbosity', default='ERROR')
27 args, _ = parser.parse_known_args() 30 args, _ = parser.parse_known_args()
28 if args.verbosity not in LOGGING_LEVELS: 31 if args.verbosity not in LOGGING_LEVELS:
29 raise argparse.ArgumentError( 32 raise argparse.ArgumentError(
30 logging_action, 'Only levels %s supported' % str(LOGGING_LEVELS)) 33 logging_action, 'Only levels %s supported' % str(LOGGING_LEVELS))
31 logging.basicConfig( 34 logging.basicConfig(
32 format='%(asctime)s %(filename)s:%(lineno)s %(levelname)s] %(message)s', 35 format='%(asctime)s %(filename)s:%(lineno)s %(levelname)s] %(message)s',
33 datefmt='%H:%M:%S', level=args.verbosity) 36 datefmt='%H:%M:%S', level=args.verbosity)
34 37
35 38
36 def ConnectToServer(server): 39 def ConnectToServer(server):
37 """Connect to an RPC server.""" 40 """Connect to an RPC server."""
38 addr = 'http://%s:%d' % (server, SERVER_PORT) 41 addr = 'http://%s:%d' % (server, SERVER_PORT)
39 logging.debug('Connecting to RPC server at %s', addr) 42 logging.debug('Connecting to RPC server at %s', addr)
40 return xmlrpclib.Server(addr) 43 return xmlrpclib.Server(addr)
OLDNEW
« no previous file with comments | « testing/legion/client_rpc_methods.py ('k') | testing/legion/examples/hello_world/host_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698