blob: 7283dfd0da562b6c436da0bae114aa0b6808689d [file] [log] [blame]
# Copyright 2015 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
import logging.handlers
import common
from autotest_lib.client.cros import constants
from autotest_lib.client.cros import dark_resume_listener
from autotest_lib.client.cros import sys_power
from autotest_lib.client.cros import xmlrpc_server
class DarkResumeXmlRpcDelegate(xmlrpc_server.XmlRpcDelegate):
"""Exposes methods called remotely during dark resume autotests.
All instance methods of this object without a preceding '_' are exposed via
an XMLRPC server. This is not a stateless handler object, which means that
if you store state inside the delegate, that state will remain around for
future calls.
def __init__(self):
super(DarkResumeXmlRpcDelegate, self).__init__()
self._listener = dark_resume_listener.DarkResumeListener()
def suspend_bg_for_dark_resume(self):
"""Suspends this system indefinitely for dark resume."""
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__':
handler = logging.handlers.SysLogHandler(address = '/dev/log')
formatter = logging.Formatter(
'dark_resume_xmlrpc_server: [%(levelname)s] %(message)s')
logging.debug('dark_resume_xmlrpc_server main...')
server = xmlrpc_server.XmlRpcServer(
'localhost', constants.DARK_RESUME_XMLRPC_SERVER_PORT)