@param address: Address of the device to disconnect. @returns: True on success. False otherwise. """ device = self._find_device(address) if not device: logging.error('Device not found') return False if not self._is_connected(device): logging.info('Device is not connected') return True device.Disconnect() return not self._is_connected(device) if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) handler = logging.handlers.SysLogHandler(address='/dev/log') formatter = logging.Formatter( 'bluetooth_device_xmlrpc_server: [%(levelname)s] %(message)s') handler.setFormatter(formatter) logging.getLogger().addHandler(handler) logging.debug('bluetooth_device_xmlrpc_server main...') server = xmlrpc_server.XmlRpcServer( 'localhost', constants.BLUETOOTH_DEVICE_XMLRPC_SERVER_PORT) server.register_delegate(BluetoothDeviceXmlRpcDelegate()) server.run()
"""Configs logging to be verbose and use console handler.""" config = logging_config.LoggingConfig() config.configure_logging(use_console=True, verbose=True) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('-d', '--debug', action='store_true', required=False, help=('create a debug console with a ServerProxy "s" ' 'connecting to the XML RPC sever at localhost')) args = parser.parse_args() if args.debug: s = xmlrpclib.ServerProxy('http://localhost:%d' % constants.MULTIMEDIA_XMLRPC_SERVER_PORT, allow_none=True) code.interact(local=locals()) else: config_logging() logging.debug('multimedia_xmlrpc_server main...') # Restart Cras to clean up any audio activities. upstart.restart_job('cras') with facade_resource.FacadeResource() as res: server = xmlrpc_server.XmlRpcServer( 'localhost', constants.MULTIMEDIA_XMLRPC_SERVER_PORT) server.register_delegate(MultimediaXmlRpcDelegate(res)) server.run()
""" def __init__(self): super(DarkResumeXmlRpcDelegate, self).__init__() self._listener = dark_resume_listener.DarkResumeListener() @xmlrpc_server.dbus_safe(None) def suspend_bg_for_dark_resume(self): """Suspends this system indefinitely for dark resume.""" sys_power.suspend_bg_for_dark_resume() @xmlrpc_server.dbus_safe(0) def get_dark_resume_count(self): """Gets the number of dark resumes that have occurred since this listener was created.""" return self._listener.count if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) handler = logging.handlers.SysLogHandler(address='/dev/log') formatter = logging.Formatter( 'dark_resume_xmlrpc_server: [%(levelname)s] %(message)s') handler.setFormatter(formatter) logging.getLogger().addHandler(handler) logging.debug('dark_resume_xmlrpc_server main...') server = xmlrpc_server.XmlRpcServer( 'localhost', constants.DARK_RESUME_XMLRPC_SERVER_PORT) server.register_delegate(DarkResumeXmlRpcDelegate()) server.run()
@xmlrpc_server.dbus_safe(False) def remove_all_wake_packet_sources(self, wifi_interface): """Stop waking on packets from any IP. @param wifi_interface: string name of interface to establish WoWLAN on. @return True on success, False otherwise. """ device_object = self._wifi_proxy.find_object(self.DBUS_DEVICE, {'Name': wifi_interface}) if device_object is None: return False device_object.RemoveAllWakeOnPacketConnections() return True if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) handler = logging.handlers.SysLogHandler(address='/dev/log') formatter = logging.Formatter( 'shill_xmlrpc_server: [%(levelname)s] %(message)s') handler.setFormatter(formatter) logging.getLogger().addHandler(handler) logging.debug('shill_xmlrpc_server main...') server = xmlrpc_server.XmlRpcServer('localhost', constants.SHILL_XMLRPC_SERVER_PORT) server.register_delegate(ShillXmlRpcDelegate()) server.run()
""" return self._apmanager_proxy.start_service(config_params) def terminate_service(self, service): """Remove/terminate an AP service. @param service string object path of the AP service. """ self._apmanager_proxy.terminate_service(service) if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) handler = logging.handlers.SysLogHandler(address='/dev/log') formatter = logging.Formatter( 'apmanager_xmlrpc_server: [%(levelname)s] %(message)s') handler.setFormatter(formatter) logging.getLogger().addHandler(handler) logging.debug('apmanager_xmlrpc_server main...') server = xmlrpc_server.XmlRpcServer('localhost', constants.APMANAGER_XMLRPC_SERVER_PORT) if server is None: raise error.TestFail('Failed to setup xmlrpc server for apmanager') else: logging.debug('Server setup') server.register_delegate(ApmanagerXmlRpcDelegate()) server.run()