Remove linux_chromium_gn_dbg from the chromium CQ.
[chromium-blink-merge.git] / testing / legion / common_lib.py
blob863f88730da9e40a3b2192a684c68a4dc54e9a51
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.
5 """Common library methods used by both coordinator and task machines."""
7 import argparse
8 import logging
9 import os
10 import socket
12 LOGGING_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'WARN', 'ERROR']
13 MY_IP = socket.gethostbyname(socket.gethostname())
14 SERVER_ADDRESS = ''
15 SERVER_PORT = 31710
16 DEFAULT_TIMEOUT_SECS = 20 * 60 # 30 minutes
17 THIS_DIR = os.path.dirname(os.path.abspath(__file__))
18 SWARMING_DIR = os.path.join(THIS_DIR, '..', '..', 'tools', 'swarming_client')
21 def InitLogging():
22 """Initialize the logging module.
24 Raises:
25 argparse.ArgumentError if the --verbosity arg is incorrect.
26 """
27 parser = argparse.ArgumentParser()
28 logging_action = parser.add_argument('--verbosity', default='INFO')
29 args, _ = parser.parse_known_args()
30 if args.verbosity not in LOGGING_LEVELS:
31 raise argparse.ArgumentError(
32 logging_action, 'Only levels %s supported' % str(LOGGING_LEVELS))
33 logging.basicConfig(
34 format='%(asctime)s %(filename)s:%(lineno)s %(levelname)s] %(message)s',
35 datefmt='%H:%M:%S', level=args.verbosity)
38 def GetOutputDir():
39 """Get the isolated output directory specified on the command line."""
40 parser = argparse.ArgumentParser()
41 parser.add_argument('--output-dir')
42 args, _ = parser.parse_known_args()
43 return args.output_dir