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

Side by Side Diff: profiling.py

Issue 6880335: Fix error when checking the request arguments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chromium-status
Patch Set: Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 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 """Profile reporting service.""" 5 """Profile reporting service."""
6 6
7 import datetime 7 import datetime
8 import logging 8 import logging
9 9
10 import simplejson as json 10 import simplejson as json
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 self.response.out.write(json.dumps(data, separators=(',',':'))) 77 self.response.out.write(json.dumps(data, separators=(',',':')))
78 78
79 def post(self): 79 def post(self):
80 """Adds a new profile report. 80 """Adds a new profile report.
81 81
82 Anyone can add a report. 82 Anyone can add a report.
83 """ 83 """
84 blacklist = ('timestamp', 'executable', 'first_arg') 84 blacklist = ('timestamp', 'executable', 'first_arg')
85 required = ('argv', 'duration', 'platform', 'domain') 85 required = ('argv', 'duration', 'platform', 'domain')
86 accepted_keys = list(set(ProfileReport.properties()) - set(blacklist)) 86 accepted_keys = list(set(ProfileReport.properties()) - set(blacklist))
87 arguments = self.request.arguments()
87 kwargs = dict( 88 kwargs = dict(
88 (k, self.request.get(k)) for k in accepted_keys if k in self.request) 89 (k, self.request.get(k)) for k in accepted_keys if k in arguments)
89 90
90 if not all(kwargs.get(k, None) for k in required): 91 if not all(kwargs.get(k, None) for k in required):
91 logging.info('missing required keys. %r' % kwargs) 92 logging.info('missing required keys. %r' % kwargs)
92 self.response.out.write('fail') 93 self.response.out.write('fail')
93 return 94 return
94 95
95 try: 96 try:
96 kwargs['duration'] = float(kwargs['duration']) 97 kwargs['duration'] = float(kwargs['duration'])
97 except ValueError: 98 except ValueError:
98 logging.info('duration(%s) is invalid' % kwargs['duration']) 99 logging.info('duration(%s) is invalid' % kwargs['duration'])
(...skipping 11 matching lines...) Expand all
110 """A cron job.""" 111 """A cron job."""
111 @utils.work_queue_only 112 @utils.work_queue_only
112 def get(self): 113 def get(self):
113 """Delete reports older than ~6 months.""" 114 """Delete reports older than ~6 months."""
114 cutoff = datetime.datetime.now() - datetime.timedelta(days=31*6) 115 cutoff = datetime.datetime.now() - datetime.timedelta(days=31*6)
115 # Will only delete 1000 reports at a time max. Shouldn't be a problem unless 116 # Will only delete 1000 reports at a time max. Shouldn't be a problem unless
116 # we get more than 1000 reports/day. 117 # we get more than 1000 reports/day.
117 for report in db.Query(ProfileReport, keys_only=True).filter( 118 for report in db.Query(ProfileReport, keys_only=True).filter(
118 'date <', cutoff): 119 'date <', cutoff):
119 db.delete(report) 120 db.delete(report)
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