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 logging | 5 import logging |
6 import os | 6 import os |
7 import sys | 7 import sys |
8 import time | 8 import time |
9 | 9 |
10 import cloudstorage | 10 import cloudstorage |
11 import flask | 11 import flask |
12 from google.appengine.api import (app_identity, taskqueue) | 12 from google.appengine.api import (app_identity, taskqueue) |
13 from google.appengine.ext import deferred | 13 from google.appengine.ext import deferred |
14 from oauth2client.client import GoogleCredentials | 14 from oauth2client.client import GoogleCredentials |
15 | 15 |
16 import common.clovis_paths | 16 import common.clovis_paths |
17 from common.clovis_task import ClovisTask | 17 from common.clovis_task import ClovisTask |
18 import common.google_bigquery_helper | 18 import common.google_bigquery_helper |
19 import common.google_instance_helper | 19 import common.google_instance_helper |
20 from common.loading_trace_database import LoadingTraceDatabase | 20 from common.loading_trace_database import LoadingTraceDatabase |
21 import email_helper | 21 import email_helper |
22 from memory_logs import MemoryLogs | 22 from memory_logs import MemoryLogs |
23 | 23 |
24 | 24 |
25 # Global variables. | 25 # Global variables. |
| 26 logging.Formatter.converter = time.gmtime |
26 clovis_logger = logging.getLogger('clovis_frontend') | 27 clovis_logger = logging.getLogger('clovis_frontend') |
27 clovis_logger.setLevel(logging.DEBUG) | 28 clovis_logger.setLevel(logging.DEBUG) |
28 project_name = app_identity.get_application_id() | 29 project_name = app_identity.get_application_id() |
29 instance_helper = common.google_instance_helper.GoogleInstanceHelper( | 30 instance_helper = common.google_instance_helper.GoogleInstanceHelper( |
30 credentials=GoogleCredentials.get_application_default(), | 31 credentials=GoogleCredentials.get_application_default(), |
31 project=project_name, | 32 project=project_name, |
32 logger=clovis_logger) | 33 logger=clovis_logger) |
33 app = flask.Flask(__name__) | 34 app = flask.Flask(__name__) |
34 | 35 |
35 | 36 |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 @app.errorhandler(404) | 457 @app.errorhandler(404) |
457 def PageNotFound(e): # pylint: disable=unused-argument | 458 def PageNotFound(e): # pylint: disable=unused-argument |
458 """Return a custom 404 error.""" | 459 """Return a custom 404 error.""" |
459 return 'Sorry, Nothing at this URL.', 404 | 460 return 'Sorry, Nothing at this URL.', 404 |
460 | 461 |
461 | 462 |
462 @app.errorhandler(500) | 463 @app.errorhandler(500) |
463 def ApplicationError(e): | 464 def ApplicationError(e): |
464 """Return a custom 500 error.""" | 465 """Return a custom 500 error.""" |
465 return 'Sorry, unexpected error: {}'.format(e), 499 | 466 return 'Sorry, unexpected error: {}'.format(e), 499 |
OLD | NEW |