当前位置: 首页>>代码示例>>Python>>正文


Python ServerProxy.run方法代码示例

本文整理汇总了Python中xmlrpclib.ServerProxy.run方法的典型用法代码示例。如果您正苦于以下问题:Python ServerProxy.run方法的具体用法?Python ServerProxy.run怎么用?Python ServerProxy.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmlrpclib.ServerProxy的用法示例。


在下文中一共展示了ServerProxy.run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import run [as 别名]
 def run(self):
     """
     Run the client and perform all the operations:
      * Connect to the server.
      * Receive video while sniffing packets.
      * Close connection.
      * Process data and extract information.
      * Run meters.
     
     :returns: A list of measures (see :attr:`VideoTester.measures.core.Meter.measures`) and the path to the temporary directory plus files prefix: ``<path-to-tempdir>/<prefix>``.
     :rtype: tuple
     """
     VTLOG.info("Client running!")
     VTLOG.info("XMLRPC Server at " + self.conf['ip'] + ':' + self.conf['port'])
     VTLOG.info("Evaluating: " + self.conf['video'] + " + " + self.conf['codec'] + " at " + self.conf['bitrate'] + " kbps and " + self.conf['framerate'] + " fps under " + self.conf['protocols'])
     from xmlrpclib import ServerProxy
     from scapy.all import rdpcap
     from multiprocessing import Process, Queue
     from VideoTester.gstreamer import RTSPclient
     from VideoTester.sniffer import Sniffer
     from VideoTester.measures.qos import QoSmeter
     from VideoTester.measures.bs import BSmeter
     from VideoTester.measures.vq import VQmeter
     try:
         server = ServerProxy('http://' + self.conf['ip'] + ':' + self.conf['port'])
         self.conf['rtspport'] = str(server.run(self.conf['bitrate'], self.conf['framerate']))
     except:
         VTLOG.error("Bad IP or port")
         exit()
     sniffer = Sniffer(self.conf)
     rtspclient = RTSPclient(self.conf, self.video)
     q = Queue()
     child = Process(target=sniffer.run, args=(q,))
     try:
         child.start()
         self.__ping()
         rtspclient.receiver()
         sniffer.cap = rdpcap(q.get())
         child.join()
     except KeyboardInterrupt:
         VTLOG.warning("Keyboard interrupt!")
         server.stop(self.conf['bitrate'], self.conf['framerate'])
         child.terminate()
         child.join()
         exit()
     server.stop(self.conf['bitrate'], self.conf['framerate'])
     videodata, size = rtspclient.reference()
     conf = {'codec':self.conf['codec'], 'bitrate':float(self.conf['bitrate']), 'framerate':float(self.conf['framerate']), 'size':size}
     packetdata = sniffer.parsePkts()
     codecdata, rawdata = self.__loadData(videodata, size, self.conf['codec'])
     qosm = QoSmeter(self.conf['qos'], packetdata).run()
     bsm = BSmeter(self.conf['bs'], codecdata).run()
     vqm = VQmeter(self.conf['vq'], (conf, rawdata, codecdata, packetdata)).run()
     self.__saveMeasures(qosm + bsm + vqm)
     VTLOG.info("Client stopped!")
     return qosm + bsm + vqm, self.conf['tempdir'] + self.conf['num']
开发者ID:Alwnikrotikz,项目名称:video-tester,代码行数:58,代码来源:core.py

示例2: run

# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import run [as 别名]
    def run(self):
        '''
        Run the client and perform all the operations:
         * Connect to the server.
         * Receive video while sniffing packets.
         * Close connection.
         * Process data and extract information.
         * Run measures.

        :returns: A dictionary of video files received (see :attr:`VideoTester.gstreamer.RTSPClient.files`), a dictionary of caps (see :attr:`VideoTester.gstreamer.RTSPClient.caps`) and a list of results
        :rtype: list
        '''
        VTLOG.info('Client running!')
        try:
            tempdir, num = self.__get_tempdir()
            server = ServerProxy('http://%s:%s' % (self.conf['ip'], self.port))
            rtspport = server.run(self.conf['bitrate'], self.conf['framerate'])
        except Exception as e:
            VTLOG.error(e)
            return None
        VTLOG.info('Connected to XMLRPC Server at %s:%s' % (self.conf['ip'], self.port))
        VTLOG.info('Evaluating: %s, %s, %s kbps, %s fps, %s' % (self.conf['video'], self.conf['codec'], self.conf['bitrate'], self.conf['framerate'], self.conf['protocol']))

        sniffer = Sniffer(self.conf['iface'],
                          self.conf['ip'],
                          '%s%s.cap' % (tempdir, num))
        rtspclient = RTSPClient(
            tempdir + num,
            self.conf['codec'],
            self.conf['bitrate'],
            self.conf['framerate']
        )
        url = 'rtsp://%s:%s/%s.%s' % (
			self.conf['ip'],
			rtspport,
			self.conf['video'],
			self.conf['codec']
		)
        child = Process(target=sniffer.run)
        ret = True
        try:
            child.start()
            VTLOG.info('PID: %s | Sniffer started' % child.pid)
            time.sleep(1)
            rtspclient.receive(url, self.conf['protocol'])
        except KeyboardInterrupt:
            VTLOG.warning('Keyboard interrupt!')
        except Exception as e:
            VTLOG.error(e)
        else:
            ret = False
        server.stop(self.conf['bitrate'], self.conf['framerate'])
        child.terminate()
        child.join()
        VTLOG.info('PID: %s | Sniffer stopped' % child.pid)
        if ret:
            return None

        video = '/'.join([self.path, dict(self.videos)[self.conf['video']]])
        rtspclient.makeReference(video)
        conf = {
            'codec': self.conf['codec'],
            'bitrate': self.conf['bitrate'],
            'framerate': self.conf['framerate'],
            'caps': rtspclient.caps
        }
        packetdata = sniffer.parsePkts(self.conf['protocol'], rtspclient.caps)
        codecdata, rawdata = self.__parseVideo(
            rtspclient.files, rtspclient.caps, self.conf['codec'])

        results = []
        results.extend(QoSmeter(self.conf['qos'], packetdata).run())
        results.extend(BSmeter(self.conf['bs'], codecdata).run())
        results.extend(VQmeter(self.conf['vq'], (conf, rawdata, codecdata, packetdata)).run())

        VTLOG.info('Saving measures...')
        for measure in results:
            f = open(tempdir + num + '_' + measure['name'] + '.pkl', 'wb')
            pickle.dump(measure, f)
            f.close()
        VTLOG.info('Client stopped!')

        return rtspclient.files, rtspclient.caps, results
开发者ID:anthcp,项目名称:video-tester,代码行数:85,代码来源:core.py

示例3: BuildbotController

# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import run [as 别名]
class BuildbotController(object):
    COMMON_OPT_FLAGS = 'c:'
    COMMON_OPT_ARGS = [
       'config=', 'buildmac_url=', 'buildwin_url=']

    DEFAULT_CONFIG_FILE = '~/.mailpile-build-controller.cfg'
    DEFAULT_PORT = 33011

    def __init__(self):
        self.config_file = os.path.expanduser(self.DEFAULT_CONFIG_FILE)
        self.buildmac_url = None
        self.buildwin_url = None
        self.running = None
        self.api = None
        if os.path.exists(self.config_file):
            self.load_config()

    def load_config(self, filename=None):
        with open(filename or self.config_file, 'r') as fd:
            lines = [l.split('#')[0].strip()
                     for l in fd.read().replace("\\\n", '').splitlines()]
        args = []
        for line in lines:
            if line:
                args.append('--%s' % line.replace(' = ', '='))
        return self.parse_args(args)

    def parse_with_common_args(self, args, opt_flags='', opt_args=[]):
        opts, args = getopt.getopt(
           args,
           '%s%s' % (opt_flags, self.COMMON_OPT_FLAGS),
           list(opt_args) + self.COMMON_OPT_ARGS)

        try:
            for opt, arg in opts:
                if opt in ('-c', '--config'):
                    self.config_file = os.path.expanduser(arg)
                    if not os.path.exists(self.config_file):
                        raise ValueError('No such file: %s' % self.config_file)
                    self.load_config()

                elif opt in ('--buildmac_url',):
                    self.buildmac_url = arg

                elif opt in ('--buildwin_url',):
                    self.buildwin_url = arg

        except ValueError as e:
            raise ArgumentError(e)

        return opts, args

    def cmd_hello(self, args):
        print 'Hello: %s' % ' '.join(args)
        args[:] = []

    def cmd_win(self, args):
        config_assert(self.buildwin_url is not None)
        self.api = ServerProxy(self.buildwin_url)
        self.running = None

    def cmd_mac(self, args):
        config_assert(self.buildmac_url is not None)
        self.api = ServerProxy(self.buildmac_url)
        self.running = None

    def cmd_run(self, args):
        config_assert(self.api is not None)
        self.running = args.pop(0)
        print('%s' % self.api.run(self.running, 1))

    def cmd_status(self, args):
        config_assert(self.api is not None)
        self.running = args.pop(0)
        print('%s' % self.api.status(self.running))

    def cmd_wait(self, args):
        config_assert(self.running is not None)
        while True:
            time.sleep(5)
            status = self.api.status(self.running)
            print('%s' % status)
            if status[-1]:
                break

    def parse_args(self, args):
        opts, args = self.parse_with_common_args(args)
        while args:
            command = args.pop(0)
            try:
                self.__getattribute__('cmd_%s' % command)(args)
            except AttributeError:
                raise ArgumentError('No such command: %s' % command)
        return self

    def run(self):
        pass

    def cleanup(self):
        pass
#.........这里部分代码省略.........
开发者ID:mailpile,项目名称:Mailpile,代码行数:103,代码来源:build-controller.py


注:本文中的xmlrpclib.ServerProxy.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。