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..e37b3aed0d4c9444b5ed8d43d4d13651a109e264 |
--- /dev/null |
+++ b/testing/legion/common_lib.py |
@@ -0,0 +1,33 @@ |
+# 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 |
+ 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)) |