Chromium Code Reviews| Index: testing/legion/common_lib.py |
| diff --git a/testing/legion/common_lib.py b/testing/legion/common_lib.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ebaa111b80d5e155a722ba255c6e0c3fd6dc3a6a |
| --- /dev/null |
| +++ b/testing/legion/common_lib.py |
| @@ -0,0 +1,34 @@ |
| +# Copyright 2015 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| +"""Common library methods. |
| + |
| +These methods can be used by both the host and the client code. |
| +""" |
| + |
| +import argparse |
| +import logging |
| +import socket |
| +import sys |
| +import xmlrpclib |
| +import SimpleXMLRPCServer |
| + |
| +LOGGING_FORMAT = ('%(asctime)s %(filename)s:%(lineno)s %(levelname)s] ' |
| + '%(message)s') |
| +LOGGING_DATE_FORMAT = '%H:%M:%S' |
| +MY_IP = socket.gethostbyname(socket.gethostname()) |
| + |
| + |
| +def InitLogging(): |
| + """Initialize the logging module.""" |
| + parser = argparse.ArgumentParser() |
| + parser.add_argument('--verbose', action='store_true') |
| + args, _ = parser.parse_known_args() |
| + level = logging.DEBUG if args.verbose else logging.INFO |
|
Marc-Antoine Ruel (Google)
2015/01/30 21:58:40
(FYI) in generally we use ERROR as default.
Mike Meade
2015/02/03 01:18:09
Unfortunately setting logging to error results in
M-A Ruel
2015/02/03 01:48:40
Ah! I can fix that later in the client code. It's
|
| + logging.basicConfig(format=LOGGING_FORMAT, datefmt=LOGGING_DATE_FORMAT, |
| + level=level) |
| + |
| + |
| +def LogCommandLine(): |
| + """Log the command line used to run this program.""" |
| + logging.debug(' '.join(sys.argv)) |