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


Python Configuration.validate方法代码示例

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


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

示例1: validate

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import validate [as 别名]
    def validate(self):
        """validate and finalize configuration"""

        self.config['remote'] = self.remote

        if self.remote:
            # setup remote
            deviceip = self.config.get('deviceip')
            deviceport = self.config['deviceport']
            if deviceip or deviceport == -1:
                self._setupRemote(deviceip, deviceport)

            # fix webserver for --develop mode
            if self.config.get('develop'):
                webserver = self.config.get('webserver')
                if (not webserver) or (webserver == 'localhost'):
                    self.config['webserver'] = utils.getLanIp()

            # webServer can be used without remoteDevice, but is required when using remoteDevice
            if self.config.get('deviceip') or self.config.get('deviceroot'):
                if self.config.get('webserver', 'localhost') == 'localhost' or not self.config.get('deviceip'):
                    raise ConfigurationError("When running Talos on a remote device, you need to provide a webServer and optionally a remotePort")

            fennecIDs = self.config.get('fennecIDs')
            if fennecIDs and not os.path.exists(fennecIDs):
                raise ConfigurationError("Unable to find fennce IDs file, please ensure this file exists: %s" % fennecIDs)

            # robocop based tests (which use fennecIDs) do not use or need the pageloader extension
            if fennecIDs:
                self.config['extensions'] = []

        # generic configuration validation
        Configuration.validate(self)

        # ensure the browser_path is specified
        msg = "Please specify --executablePath"
        if not 'print_tests' in self.parsed and not self.config.get('browser_path'):
            self.error(msg)

        # add test_name_extension to config
        # http://hg.mozilla.org/build/talos/file/c702ff8892be/talos/PerfConfigurator.py#l107
        noChrome = self.config.get('noChrome')
        mozAfterPaint = self.config.get('tpmozafterpaint')
        if noChrome or mozAfterPaint and not self.config.get('test_name_extension'):
            # (it would be nice to handle this more elegantly)
            test_name_extension = ''
            if noChrome:
                test_name_extension += '_nochrome'
            if mozAfterPaint:
                test_name_extension += '_paint'
            self.config['test_name_extension'] = test_name_extension

        # BBB: (resultsServer, resultsLink) -> results_url
        resultsServer = self.config.pop('resultsServer', None)
        resultsLink = self.config.pop('resultsLink', None)
        if resultsServer and resultsLink:
            if self.config.get('results_urls'):
                raise Configuration("Can't user resultsServer/resultsLink and results_url: use results_url instead")
            self.config['results_urls'] = ['http://%s%s' % (resultsServer, resultsLink)]

        # BBB: remove doubly-quoted xperf values from command line
        # (needed for buildbot)
        # https://bugzilla.mozilla.org/show_bug.cgi?id=704654#c43
        xperf_path = self.config.get('xperf_path', '')
        if 'xperf_path' in self.parsed and len(xperf_path) > 2:
            quotes = ('"', "'")
            for quote in quotes:
                if xperf_path.startswith(quote) and xperf_path.endswith(quote):
                    self.config['xperf_path'] = xperf_path[1:-1]
                    break

        # fix options for --develop
        if self.config.get('develop'):
            if not self.config.get('webserver'):
                self.config['webserver'] = 'localhost:%s' % utils.findOpenPort('127.0.0.1')

        # set preferences
        if self.config.get('tpmozafterpaint'):
            self.config['preferences']['dom.send_after_paint_to_content'] = True
        extraPrefs = self.config.pop('extraPrefs', {})
        extraPrefs = dict([(i, utils.parsePref(j)) for i, j in extraPrefs.items()])
        self.config['preferences'].update(extraPrefs)
        # remove None values from preferences;
        # allows overrides
        self.config['preferences'] = dict([(key,value)
                                           for key, value in self.config['preferences'].items()
                                           if value is not None])
        # fix talos.logfile preference to be an absolute path
        # http://hg.mozilla.org/build/talos/file/e1022c38a8ed/talos/PerfConfigurator.py#l129
        if 'talos.logfile' in self.config['preferences']:
            # if set to empty string, use the "global" browser_log
            # in practice these should always be in sync
            log_file = self.config['preferences']['talos.logfile'].strip() or self.config['browser_log']
            log_file = os.path.abspath(log_file)
            self.config['preferences']['talos.logfile'] = log_file

        if 'init_url' in self.config:
            # fix init_url
            self.config['init_url'] = self.convertUrlToRemote(self.config['init_url'])

#.........这里部分代码省略.........
开发者ID:djmitche,项目名称:build-talos,代码行数:103,代码来源:PerfConfigurator.py


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