예제 #1
0
    def __init__(self, _env_var_=None):
        """
        constructor
        """
        self._dataMaps = []

        # load default yaml file if this is not a unit test.
        try:
            if _env_var_ != None: 
                # We pass in a custom env var for unit testing.
                configs = re.split(",|;", _env_var_)
                for config in reversed(configs):
                    self.__load_config_file(config)
            elif not ConfigReader.ENV_VARS in os.environ:
                _wtflog.warning(u("Config file not specified.  Using config/defaults.yaml"))
                self.__load_config_file(ConfigReader.DEFAULT_CONFIG_FILE)
            else:
                # Read and load in all configs specified in reverse order
                configs = re.split(",|;", str(os.environ[ConfigReader.ENV_VARS]))
                for config in reversed(configs):
                    self.__load_config_file(config)

                
        except Exception as e:
            # Fall back to default.yaml file when no config settings are specified.
            _wtflog.error(u("An error occurred while loading config file: %s"), e)
            raise e
예제 #2
0
    def __init__(self, _env_var_=None):
        """
        constructor
        """
        self._dataMaps = []

        # load default yaml file if this is not a unit test.
        try:
            if _env_var_ != None:
                # We pass in a custom env var for unit testing.
                configs = re.split(",|;", _env_var_)
                for config in reversed(configs):
                    self.__load_config_file(config)
            elif not ConfigReader.ENV_VARS in os.environ:
                _wtflog.warning(
                    u("Config file not specified.  Using config/defaults.yaml")
                )
                self.__load_config_file(ConfigReader.DEFAULT_CONFIG_FILE)
            else:
                # Read and load in all configs specified in reverse order
                configs = re.split(",|;",
                                   str(os.environ[ConfigReader.ENV_VARS]))
                for config in reversed(configs):
                    self.__load_config_file(config)

        except Exception as e:
            # Fall back to default.yaml file when no config settings are
            # specified.
            _wtflog.error(u("An error occurred while loading config file: %s"),
                          e)
            raise e
예제 #3
0
    def __init__(self, _env_var_=None):
        """
        constructor
        """
        self._dataMaps = []

        # load default yaml file if this is not a unit test.
        try:
            if _env_var_ is not None:
                # We pass in a custom env var for unit testing.
                configs = re.split(",|;", _env_var_)
                for config in reversed(configs):
                    self.__load_config_file(config)
            elif not ConfigReader.ENV_VARS in os.environ:
                _wtflog.warning(u("Config file not specified. Using:{0}")\
                                .format(os.path.join(ConfigReader.CONFIG_LOCATION,
                                                     ConfigReader.DEFAULT_CONFIG_FILE + ConfigReader.CONFIG_EXT)))
                self.__load_config_file(ConfigReader.DEFAULT_CONFIG_FILE)
            else:
                # Read and load in all configs specified in reverse order
                configs = re.split(",|;",
                                   str(os.environ[ConfigReader.ENV_VARS]))
                for config in reversed(configs):
                    self.__load_config_file(config)

        except Exception as e:
            # Error loading config file.
            _wtflog.error(u("An error occurred while loading config file: %s"),
                          e)
            raise e
예제 #4
0
    def __init__(self, _env_var_=None):
        """
        constructor
        """
        self._dataMaps = []

        # load default yaml file if this is not a unit test.
        try:
            if _env_var_ is not None:
                # We pass in a custom env var for unit testing.
                configs = re.split(",|;", _env_var_)
                for config in reversed(configs):
                    self.__load_config_file(config)
            elif not ConfigReader.ENV_VARS in os.environ:
                _wtflog.warning(u("Config file not specified. Using:{0}")\
                                .format(os.path.join(ConfigReader.CONFIG_LOCATION,
                                                     ConfigReader.DEFAULT_CONFIG_FILE + ConfigReader.CONFIG_EXT)))
                self.__load_config_file(ConfigReader.DEFAULT_CONFIG_FILE)
            else:
                # Read and load in all configs specified in reverse order
                configs = re.split(
                    ",|;", str(os.environ[ConfigReader.ENV_VARS]))
                for config in reversed(configs):
                    self.__load_config_file(config)

        except Exception as e:
            # Error loading config file.
            _wtflog.error(
                u("An error occurred while loading config file: %s"), e)
            raise e
예제 #5
0
    def __take_screenshot_if_webdriver_open__(self, testcase):
        '''
        Take a screenshot if webdriver is open.

        Args:
            testcase: TestCase

        '''
        if self._webdriver_provider.is_driver_available():
            try:
                name = self.__generate_screenshot_filename__(testcase)
                self._screenshot_util.take_screenshot(
                    self._webdriver_provider.get_driver(), name)
                _wtflog.warning("Screenshot taken: %s", name)
            except Exception as e:
                _wtflog.warning("Unable to take screenshot. Reason: %s",
                                e.message)
예제 #6
0
    def __take_screenshot_if_webdriver_open__(self, testcase):
        '''
        Take a screenshot if webdriver is open.

        Args:
            testcase: TestCase

        '''
        if self._webdriver_provider.is_driver_available():
            try:
                name = self.__generate_screenshot_filename__(testcase)
                self._screenshot_util.take_screenshot(
                    self._webdriver_provider.get_driver(), name)
                _wtflog.warning("Screenshot taken: %s", name)
            except Exception as e:
                _wtflog.warning(
                    "Unable to take screenshot. Reason: %s", e.message)