def get(): global loggers if len(loggers) > 0: return loggers[0] else: todays_date = str(datetime.date.today()) logs_dir = create_directory('/tmp/coyote_framework/logs/' + todays_date) logs_file = logs_dir + '/' + todays_date + '.log' logging.basicConfig(format=FORMAT, datefmt=DATE_FORMAT, filename=logs_file, filemode='w') # logging streamhandler for log files _file = logging.StreamHandler() _file.setFormatter(logging.Formatter(FORMAT)) _file.setLevel(DEFAULT_LEVEL) # logging streamhandler for standardout output = logging.StreamHandler(sys.stdout) logger = logging.getLogger(todays_date) logger.addHandler(logging.FileHandler(logs_file)) logger.addHandler(output) logger.addHandler(_file) loggers.append(logger) return logger
def get_firefox_binary(): """Gets the firefox binary @rtype: FirefoxBinary """ browser_config = BrowserConfig() constants_config = ConstantsConfig() log_dir = os.path.join(constants_config.get('logs_dir'), 'firefox') create_directory(log_dir) log_path = os.path.join(log_dir, '{}_{}.log'.format(datetime.datetime.now().isoformat('_'), words.random_word())) log_file = open(log_path, 'w') log('Firefox log file: {}'.format(log_path)) binary = FirefoxBinary(log_file=log_file) return binary
def get_firefox_profile(): # TODO: update this so that it is not browser-specific constants_config = ConstantsConfig() profile_directory = os.path.join(constants_config.get('webdriver_dir'), 'firefox', 'profile', 'tmp') create_directory(profile_directory) ffprofile = webdriver.FirefoxProfile(profile_directory) log_dir = os.path.join(constants_config.get('logs_dir'), 'webdriver') create_directory(log_dir) log_path = os.path.join(log_dir, '{}_{}.log'.format(datetime.datetime.now().isoformat('_'), words.random_word())) log('Selenium log file: {}'.format(log_path)) # Accept firefox profiles ffprofile.set_preference('webdriver.log.file', log_path) return ffprofile
def get_firefox_binary(): """Gets the firefox binary @rtype: FirefoxBinary """ browser_config = BrowserConfig() constants_config = ConstantsConfig() log_dir = os.path.join(constants_config.get('logs_dir'), 'firefox') create_directory(log_dir) log_path = os.path.join( log_dir, '{}_{}.log'.format(datetime.datetime.now().isoformat('_'), words.random_word())) log_file = open(log_path, 'w') log('Firefox log file: {}'.format(log_path)) binary = FirefoxBinary(log_file=log_file) return binary
def get_firefox_profile(): # TODO: update this so that it is not browser-specific constants_config = ConstantsConfig() profile_directory = os.path.join(constants_config.get('webdriver_dir'), 'firefox', 'profile', 'tmp') create_directory(profile_directory) ffprofile = webdriver.FirefoxProfile(profile_directory) log_dir = os.path.join(constants_config.get('logs_dir'), 'webdriver') create_directory(log_dir) log_path = os.path.join( log_dir, '{}_{}.log'.format(datetime.datetime.now().isoformat('_'), words.random_word())) log('Selenium log file: {}'.format(log_path)) # Accept firefox profiles ffprofile.set_preference('webdriver.log.file', log_path) return ffprofile