Пример #1
0
 def cleanup(self):
     utils.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))
     utils.restart_job('powerd')
 def finalize(self):
     """finalize"""
     if os.path.exists(self._TEMPDIR):
         utils.system('umount %s' % self._PREFDIR, ignore_status=True)
         shutil.rmtree(self._TEMPDIR)
         utils.restart_job('powerd')
Пример #4
0
    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'))
    parser.add_argument('--restart',
                        action='store_true',
                        required=False,
                        help=('restart the XML RPC server without clearing '
                              'the previous state'))
    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.
        utils.restart_job('cras')

        with facade_resource.FacadeResource(restart=args.restart) as res:
            server = xmlrpc_server.XmlRpcServer(
                'localhost', constants.MULTIMEDIA_XMLRPC_SERVER_PORT)
            server.register_delegate(MultimediaXmlRpcDelegate(res))
            server.run()