示例#1
0
    def configure(self, options, conf):
        """
        Called after the command  line has been parsed, with the parsed options and the config container. Here, implement any config storage or changes to state or operation that are set by command line options. DO NOT return a value from this method unless you want to stop all other plugins from being configured.
        """
        super(ReporterPlugin, self).configure(options, conf)
        if not self.enabled: return

        self.write_hashes = conf.verbosity == 2
        self.conf = conf
        self.opt = options
        if self.opt.icycle and not self.__counter:
            self.__counter = TestCounter(cycles=self.opt.icycle)
        elif not self.__counter:
            self.__counter = TestCounter()

        if self.opt.duration and not self.__timer:
            self.__timer = Timer(self.opt.duration)

        if not self.__configuration:
            if self.opt.reportserver:
                if not exists(options.server_config):
                    raise Exception(
                        'exit due to unable to find server configuration file: "%s"'
                        % options.server_config)
            if not exists(options.device_config):
                raise Exception(
                    'exit due to unable to find device configuration file: "%s"'
                    % options.device_config)
            self.__configuration.update(
                _getServerConfiguration(options.server_config))
            self.__configuration.update(
                _getDeviceConfiguration(options.device_config))
            self.__configuration.update(
                {'planname': os.path.basename(self.conf.options.plan_file)})

        self.result_properties = {'payload': None, 'extras': None}
        #if disable report server
        if self.opt.reportserver and not self.__report_client:
            server_need = {
                'username': None,
                'password': None,
                'auth': None,
                'session_create': None,
                'session_update': None,
                'case_create': None,
                'case_update': None,
                'file_upload': None
            }
            self.__report_client = ReportClient(**self.__configuration)
            self.token = self.__report_client.regist()
            if not self.token:
                raise Exception('exit due to unable to get token from server!')