<commit_before># -*- coding: utf-8 -*-
'''
(c) Copyright 2014 Telefonica, I+D. Printed in Spain (Europe). All Rights
Reserved.

The copyright to the software program(s) is property of Telefonica I+D.
The program(s) may be used and or copied only with the express written
consent of Telefonica I+D or in accordance with the terms and conditions
stipulated in the agreement/contract under which the program(s) have
been supplied.
'''
import logging.config
import os
import datetime
from seleniumtid.config_driver import ConfigDriver
from seleniumtid.config_parser import ExtendedConfigParser


class SeleniumWrapper(object):
    # Singleton instance
    _instance = None
    driver = None
    logger = None
    config = ExtendedConfigParser()
    conf_properties_files = None
    conf_logging_file = None
    browser_info = None
    screenshots_path = None
    screenshots_number = None
    videos_path = None
    videos_number = None
    output_directory = None
    baseline_directory = None
    visual_number = None

    def __new__(cls, *args, **kwargs):
        if not cls._instance:
            # Create new instance
            cls._instance = super(SeleniumWrapper, cls).__new__(cls, *args, **kwargs)
        return cls._instance

    def configure_logger(self):
        '''
        Configure selenium instance logger
        '''
        # Get logging filename from system properties
        try:
            conf_logging_file = os.environ["Files_logging"]
        except KeyError:
            conf_logging_file = 'conf/logging.conf'

        # Configure logger if logging filename has changed
        if self.conf_logging_file != conf_logging_file:
            try:
                logging.config.fileConfig(conf_logging_file, None, False)
            except Exception as exc:
                print "[WARN] Error reading logging config file '{}': {}".format(conf_logging_file, exc)
            self.conf_logging_file = conf_logging_file
            self.logger = logging.getLogger(__name__)

    def configure_properties(self):
        '''
        Configure selenium instance properties<commit_msg>Allow to set logger filename with a system property<commit_after># -*- coding: utf-8 -*-
'''
(c) Copyright 2014 Telefonica, I+D. Printed in Spain (Europe). All Rights
Reserved.

The copyright to the software program(s) is property of Telefonica I+D.
The program(s) may be used and or copied only with the express written
consent of Telefonica I+D or in accordance with the terms and conditions
stipulated in the agreement/contract under which the program(s) have
been supplied.
'''
import logging.config
import os
import datetime
from seleniumtid.config_driver import ConfigDriver
from seleniumtid.config_parser import ExtendedConfigParser


class SeleniumWrapper(object):
    # Singleton instance
    _instance = None
    driver = None
    logger = None
    config = ExtendedConfigParser()
    conf_properties_files = None
    conf_logging_file = None
    browser_info = None
    screenshots_path = None
    screenshots_number = None
    videos_path = None
    videos_number = None
    output_directory = None
    baseline_directory = None
    visual_number = None

    def __new__(cls, *args, **kwargs):
        if not cls._instance:
            # Create new instance
            cls._instance = super(SeleniumWrapper, cls).__new__(cls, *args, **kwargs)
        return cls._instance

    def configure_logger(self):
        '''
        Configure selenium instance logger
        '''
        # Get logging filename from system properties
        try:
            conf_logging_file = os.environ["Files_logging"]
        except KeyError:
            conf_logging_file = 'conf/logging.conf'
        try:
            log_filename = os.path.normpath(os.environ["Files_log_filename"]).replace('\\', '\\\\')
        except KeyError:
            log_filename = 'selenium.log'

        # Configure logger if logging filename has changed
        if self.conf_logging_file != conf_logging_file:
            try:
                logging.config.fileConfig(conf_logging_file, {'logfilename': log_filename}, False)
            except Exception as exc:
                print "[WARN] Error reading logging config file '{}': {}".format(conf_logging_file, exc)
            self.conf_logging_file = conf_logging_file
            self.logger = logging.getLogger(__name__)

    def configure_properties(self):
        '''
        Configure selenium instance properties
{'fraction_non_alphanumeric': 0.07526398562120871, 'fraction_numerical': 0.0022466861379465287, 'mean_word_length': 2.8478824546240276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2623689', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1156, 'n_words': 377}