Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(691)

Side by Side Diff: handler.py

Issue 11876008: Fix for handling pages without a timestamp. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chromium-build
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 urllib 5 import urllib
6 6
7 from google.appengine.ext import deferred 7 from google.appengine.ext import deferred
8 # F0401: 9,0: Unable to import 'webapp2' 8 # F0401: 9,0: Unable to import 'webapp2'
9 # pylint: disable=F0401 9 # pylint: disable=F0401
10 import webapp2 10 import webapp2
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 num_revs = utils.clean_int(num_revs, -1) 75 num_revs = utils.clean_int(num_revs, -1)
76 if num_revs <= 0: 76 if num_revs <= 0:
77 num_revs = None 77 num_revs = None
78 app.console_merger(unquoted_localpath, 'console/chromium', page_data, 78 app.console_merger(unquoted_localpath, 'console/chromium', page_data,
79 num_rows_to_merge=num_revs) 79 num_rows_to_merge=num_revs)
80 return app.get_and_cache_pagedata(unquoted_localpath) 80 return app.get_and_cache_pagedata(unquoted_localpath)
81 81
82 82
83 def recent_page(page_data): 83 def recent_page(page_data):
84 ts = page_data.get('fetch_timestamp') 84 ts = page_data.get('fetch_timestamp')
85 if not ts:
86 return False
85 now = app.datetime.datetime.now() 87 now = app.datetime.datetime.now()
86 if isinstance(ts, app.datetime.datetime): 88 if isinstance(ts, app.datetime.datetime):
87 delta = now - ts 89 delta = now - ts
88 else: 90 else:
89 delta = now - app.datetime.datetime.strptime(ts, "%Y-%m-%dT%H:%M:%S.%f") 91 delta = now - app.datetime.datetime.strptime(ts, "%Y-%m-%dT%H:%M:%S.%f")
90 return delta < app.datetime.timedelta(minutes=1) 92 return delta < app.datetime.timedelta(minutes=1)
91 93
92 94
93 class FetchPagesAction(base_page.BasePage): 95 class FetchPagesAction(base_page.BasePage):
94 96
(...skipping 14 matching lines...) Expand all
109 app.bootstrap() 111 app.bootstrap()
110 base_page.bootstrap() 112 base_page.bootstrap()
111 113
112 # GAE will cache |application| across requests if we set it here. See 114 # GAE will cache |application| across requests if we set it here. See
113 # http://code.google.com/appengine/docs/python/runtime.html#App_Caching for more 115 # http://code.google.com/appengine/docs/python/runtime.html#App_Caching for more
114 # info. 116 # info.
115 application = webapp2.WSGIApplication( 117 application = webapp2.WSGIApplication(
116 [('/', MainAction), 118 [('/', MainAction),
117 ('/p/(.*)', PageAction), 119 ('/p/(.*)', PageAction),
118 ('/tasks/fetch_pages', FetchPagesAction)]) 120 ('/tasks/fetch_pages', FetchPagesAction)])
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698