blob: c6730982ac863ba614db7ee1529a98225e2488bf [file] [log] [blame]
Sanika Kulkarniff079b02020-07-08 15:55:36 -07001# -*- coding: utf-8 -*-
2# Copyright 2020 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""An cherry app to play as a fake Telemetry service.
7
8This is a short term solution in order to deprecation devserver.py from labs.
9"""
Sanika Kulkarniff079b02020-07-08 15:55:36 -070010from __future__ import print_function
11
12import cherrypy # pylint: disable=import-error
Sanika Kulkarni80e5bd72020-07-21 18:34:34 -070013import telemetry_setup
Sanika Kulkarniff079b02020-07-08 15:55:36 -070014
15
16def get_config():
17 """Get cherrypy config for this application."""
18 return {
19 '/': {
20 'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
21 }
22 }
23
24
25@cherrypy.expose
26class FakeTelemetry(object):
27 """An application to handle fake telemetry requests."""
28 def GET(self, **kwargs):
29 """A URL handler for setting up telemetry."""
30 archive_url = kwargs.get('archive_url')
Sanika Kulkarni80e5bd72020-07-21 18:34:34 -070031 with telemetry_setup.TelemetrySetup(archive_url) as tlm:
32 return tlm.Setup()