Sanika Kulkarni | ff079b0 | 2020-07-08 15:55:36 -0700 | [diff] [blame] | 1 | # -*- 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 | |
| 8 | This is a short term solution in order to deprecation devserver.py from labs. |
| 9 | """ |
Sanika Kulkarni | ff079b0 | 2020-07-08 15:55:36 -0700 | [diff] [blame] | 10 | from __future__ import print_function |
| 11 | |
| 12 | import cherrypy # pylint: disable=import-error |
Sanika Kulkarni | 80e5bd7 | 2020-07-21 18:34:34 -0700 | [diff] [blame] | 13 | import telemetry_setup |
Sanika Kulkarni | ff079b0 | 2020-07-08 15:55:36 -0700 | [diff] [blame] | 14 | |
| 15 | |
| 16 | def 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 |
| 26 | class 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 Kulkarni | 80e5bd7 | 2020-07-21 18:34:34 -0700 | [diff] [blame] | 31 | with telemetry_setup.TelemetrySetup(archive_url) as tlm: |
| 32 | return tlm.Setup() |