def restart(self): """ Restarts authpolicyd and rebinds to D-Bus interface. """ logging.info('restarting authpolicyd') upstart.restart_job('authpolicyd') bus = dbus.SystemBus(self._bus_loop) proxy = bus.get_object(self._DBUS_SERVICE_NAME, self._DBUS_SERVICE_PATH) self._authpolicyd = dbus.Interface(proxy, self._DBUS_INTERFACE_NAME)
def restart(self): """ Restarts smbproviderd and rebinds to D-Bus interface. """ logging.info('restarting smbproviderd') upstart.restart_job('smbproviderd') try: # Get the interface as Chronos since only they are allowed to send # D-Bus messages to smbproviderd. os.setresuid(self._CHRONOS_UID, self._CHRONOS_UID, 0) bus = dbus.SystemBus(self._bus_loop) proxy = bus.get_object(self._DBUS_SERVICE_NAME, self._DBUS_SERVICE_PATH) self._smbproviderd = dbus.Interface(proxy, self._DBUS_INTERFACE_NAME) finally: os.setresuid(0, 0, 0)
def run_upstart_tests(self): """ Run some sanity tests for cupsd and the upstart-socket-bridge socket-activation. """ upstart.ensure_running('upstart-socket-bridge') if not self.wait_for_path_exists(self._CUPS_SOCK_PATH): raise error.TestFail('Missing CUPS socket: %s', self._CUPS_SOCK_PATH) # Make sure CUPS is stopped, so we can test on-demand launch. if upstart.is_running('cupsd'): upstart.stop_job('cupsd') self.check_cups_is_responding() # Now try stopping socket bridge, to see it clean up its files. upstart.stop_job('upstart-socket-bridge') upstart.stop_job('cupsd') if os.path.exists(self._CUPS_SOCK_PATH): raise error.TestFail('CUPS socket was not cleaned up: %s', self._CUPS_SOCK_PATH) # Create dummy file, to see if upstart-socket-bridge will clear it out # properly. utils.system('touch %s' % self._CUPS_SOCK_PATH) upstart.restart_job('upstart-socket-bridge') if not os.path.exists(self._CUPS_SOCK_PATH): raise error.TestFail('Missing CUPS socket: %s', self._CUPS_SOCK_PATH) self.check_cups_is_responding()
def cleanup(self): """ Cleanup powerd after test. """ upstart.restart_job('powerd')
"""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 finalize(self): """finalize""" if os.path.exists(self._TEMPDIR): utils.system('umount %s' % self._PREFDIR, ignore_status=True) shutil.rmtree(self._TEMPDIR) upstart.restart_job('powerd')
def __init__(self, prefs): shutil.copytree(self._PREFDIR, self._TEMPDIR) for name, value in prefs.iteritems(): utils.write_one_line('%s/%s' % (self._TEMPDIR, name), value) utils.system('mount --bind %s %s' % (self._TEMPDIR, self._PREFDIR)) upstart.restart_job('powerd')
def _saw_dark_resume(self, unused): self._count += 1 if self._stop_resuspend: # Restart powerd to stop re-suspend. upstart.restart_job('powerd')