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."""
12 LOGGING_LEVELS
= ['DEBUG', 'INFO', 'WARNING', 'WARN', 'ERROR']
13 MY_IP
= socket
.gethostbyname(socket
.gethostname())
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')
22 """Initialize the logging module.
25 argparse.ArgumentError if the --verbosity arg is incorrect.
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
))
34 format
='%(asctime)s %(filename)s:%(lineno)s %(levelname)s] %(message)s',
35 datefmt
='%H:%M:%S', level
=args
.verbosity
)
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