| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import argparse | 5 import argparse |
| 6 import json | 6 import json |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 import time |
| 10 | 11 |
| 11 from googleapiclient import discovery | 12 from googleapiclient import discovery |
| 12 from oauth2client.client import GoogleCredentials | 13 from oauth2client.client import GoogleCredentials |
| 13 | 14 |
| 14 # NOTE: The parent directory needs to be first in sys.path to avoid conflicts | 15 # NOTE: The parent directory needs to be first in sys.path to avoid conflicts |
| 15 # with catapult modules that have colliding names, as catapult inserts itself | 16 # with catapult modules that have colliding names, as catapult inserts itself |
| 16 # into the path as the second element. This is an ugly and fragile hack. | 17 # into the path as the second element. This is an ugly and fragile hack. |
| 17 _CLOUD_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), | 18 _CLOUD_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), |
| 18 os.pardir) | 19 os.pardir) |
| 19 sys.path.insert(0, os.path.join(_CLOUD_DIR, os.pardir)) | 20 sys.path.insert(0, os.path.join(_CLOUD_DIR, os.pardir)) |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 # any time. | 199 # any time. |
| 199 | 200 |
| 200 if __name__ == '__main__': | 201 if __name__ == '__main__': |
| 201 parser = argparse.ArgumentParser( | 202 parser = argparse.ArgumentParser( |
| 202 description='ComputeEngine Worker for Clovis') | 203 description='ComputeEngine Worker for Clovis') |
| 203 parser.add_argument('--config', required=True, | 204 parser.add_argument('--config', required=True, |
| 204 help='Path to the configuration file.') | 205 help='Path to the configuration file.') |
| 205 args = parser.parse_args() | 206 args = parser.parse_args() |
| 206 | 207 |
| 207 # Configure logging. | 208 # Configure logging. |
| 208 logging.basicConfig(level=logging.WARNING) | 209 logging.basicConfig(level=logging.WARNING, |
| 210 format='[%(asctime)s][%(levelname)s] %(message)s', |
| 211 datefmt='%y-%m-%d %H:%M:%S') |
| 212 logging.Formatter.converter = time.gmtime |
| 209 worker_logger = logging.getLogger('worker') | 213 worker_logger = logging.getLogger('worker') |
| 210 worker_logger.setLevel(logging.INFO) | 214 worker_logger.setLevel(logging.INFO) |
| 211 | 215 |
| 212 worker_logger.info('Reading configuration') | 216 worker_logger.info('Reading configuration') |
| 213 with open(args.config) as config_json: | 217 with open(args.config) as config_json: |
| 214 worker = Worker(json.load(config_json), worker_logger) | 218 worker = Worker(json.load(config_json), worker_logger) |
| 215 worker.Start() | 219 worker.Start() |
| OLD | NEW |