Add cron job to update list of blink components
This commit is contained in:
Родитель
5a525734d1
Коммит
97ba7e5b10
11
admin.py
11
admin.py
|
@ -190,7 +190,7 @@ class HistogramsHandler(webapp2.RequestHandler):
|
|||
|
||||
def get(self):
|
||||
# Attempt to fetch enums mapping file.
|
||||
result = urlfetch.fetch(HISTOGRAMS_URL)
|
||||
result = urlfetch.fetch(HISTOGRAMS_URL, deadline=60)
|
||||
|
||||
if (result.status_code != 200):
|
||||
logging.error('Unable to retrieve chromium histograms mapping file.')
|
||||
|
@ -427,9 +427,18 @@ class FeatureHandler(common.ContentHandler):
|
|||
|
||||
return self.redirect(redirect_url)
|
||||
|
||||
|
||||
class BlinkComponentHandler(webapp2.RequestHandler):
|
||||
"""Updates the list of Blink components in the db."""
|
||||
def get(self):
|
||||
models.BlinkComponent.update_db()
|
||||
self.response.out.write('Blink components updated')
|
||||
|
||||
|
||||
app = webapp2.WSGIApplication([
|
||||
('/cron/metrics', YesterdayHandler),
|
||||
('/cron/histograms', HistogramsHandler),
|
||||
('/cron/update_blink_components', BlinkComponentHandler),
|
||||
('/(.*)/([0-9]*)', FeatureHandler),
|
||||
('/(.*)', FeatureHandler),
|
||||
], debug=settings.DEBUG)
|
||||
|
|
|
@ -5,3 +5,6 @@ cron:
|
|||
- description: retrieve from UMA Cloud Storage data gathered yesterday
|
||||
url: /cron/metrics
|
||||
schedule: every day 22:00
|
||||
- desription: update list of Blink components
|
||||
url: /cron/update_blink_components
|
||||
schedule: every day 04:30
|
|
@ -236,7 +236,7 @@ class BlinkComponent(DictModel):
|
|||
components = memcache.get(key)
|
||||
if components is None or update_cache:
|
||||
components = []
|
||||
result = urlfetch.fetch(self.COMPONENTS_URL)
|
||||
result = urlfetch.fetch(self.COMPONENTS_URL, deadline=60)
|
||||
if result.status_code == 200:
|
||||
components = sorted(json.loads(result.content))
|
||||
memcache.set(key, components)
|
||||
|
@ -250,7 +250,6 @@ class BlinkComponent(DictModel):
|
|||
for name in new_components:
|
||||
if not len([x.name for x in existing_comps if x.name == name]):
|
||||
logging.info('Adding new BlinkComponent: ' + name)
|
||||
print 'Adding new BlinkComponent: ' + name
|
||||
c = BlinkComponent(name=name)
|
||||
c.put()
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче