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

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

Issue 890773003: Adding the initial code for Omnibot multi-machine support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing some silly subprocess code. 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
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 """Common library methods used by both host and client controllers."""
6
7 import argparse
8 import logging
9 import socket
10 import sys
11 import xmlrpclib
12
13 LOGGING_FORMAT = ('%(asctime)s %(filename)s:%(lineno)s %(levelname)s] '
M-A Ruel 2015/02/03 01:48:41 I'd probably wouldn't make it a named constant unl
Mike Meade 2015/02/03 17:47:57 Done.
14 '%(message)s')
15 LOGGING_DATE_FORMAT = '%H:%M:%S'
16 LOGGING_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'WARN', 'ERROR']
17 MY_IP = socket.gethostbyname(socket.gethostname())
18 SERVER_ADDRESS = ''
19 SERVER_PORT = 31710
20 DEFAULT_TIMEOUT_SECS = 20 * 60 # 30 minutes
21
22
23 def InitLogging():
24 """Initialize the logging module.
25
26 Raises:
27 argparse.ArgumentError if the --verbosity arg is incorrect.
28 """
29 parser = argparse.ArgumentParser()
30 logging_action = parser.add_argument('--verbosity', default='ERROR')
M-A Ruel 2015/02/03 01:48:41 I generally use instead action='count' then use it
Mike Meade 2015/02/03 17:47:57 Acknowledged.
31 args, _ = parser.parse_known_args()
32 if args.verbosity not in LOGGING_LEVELS:
33 raise argparse.ArgumentError(
34 logging_action, 'Only levels %s supported' % str(LOGGING_LEVELS))
35 logging.basicConfig(format=LOGGING_FORMAT, datefmt=LOGGING_DATE_FORMAT,
36 level=args.verbosity)
37
38
39 def PrintCommandLine():
M-A Ruel 2015/02/03 01:48:41 What's the use case? In particular I don't think t
Mike Meade 2015/02/03 17:47:57 Done.
40 """Print the command line used to run this program."""
41 print ' '.join(sys.argv)
42
43
44 def ConnectToServer(server):
45 """Connect to an RPC server."""
46 addr = 'http://%s:%d' % (server, SERVER_PORT)
47 logging.debug('Connecting to RPC server at %s', addr)
48 return xmlrpclib.Server(addr)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698