• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python2
2
3# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7from __future__ import absolute_import
8from __future__ import division
9from __future__ import print_function
10
11import logging
12import logging.handlers
13
14import common
15from autotest_lib.client.cros import constants
16from autotest_lib.client.cros import xmlrpc_server
17from autotest_lib.client.cros.multimedia import bluetooth_facade_native
18
19
20class BluetoothDeviceXmlRpcDelegate(
21        xmlrpc_server.XmlRpcDelegate,
22        bluetooth_facade_native.BluetoothFacadeNative):
23    """Exposes DUT methods called remotely during Bluetooth autotests.
24
25    The delegate inherits from BluetoothFacadeNative where all native calls
26    should be kept. This XmlRpcDelegate is kept around for when Bluetooth needs
27    to be called without using the MultimediaRpcDelegate.
28
29    TODO(abps): Remove this xmlrpc delegate once it's no longer used.
30    """
31
32    def __init__(self):
33        super(BluetoothDeviceXmlRpcDelegate, self).__init__()
34
35if __name__ == '__main__':
36    logging.basicConfig(level=logging.DEBUG)
37    handler = logging.handlers.SysLogHandler(address='/dev/log')
38    formatter = logging.Formatter(
39            'bluetooth_device_xmlrpc_server: [%(levelname)s] %(message)s')
40    handler.setFormatter(formatter)
41    logging.getLogger().addHandler(handler)
42    logging.debug('bluetooth_device_xmlrpc_server main...')
43    server = xmlrpc_server.XmlRpcServer(
44            'localhost', constants.BLUETOOTH_DEVICE_XMLRPC_SERVER_PORT)
45    server.register_delegate(BluetoothDeviceXmlRpcDelegate())
46    server.run()
47