Exemple #1
0
def get_saucelabs_connect(config=None, config_path=None, update=False):
    '''
    Downloads saucelabs connect binary into **config.saucelabs.connect.path**

    :param pymlconf.ConfigManager config: configuration object
    :param str config_path: path to config
    :param bool update: - (optional) if True overwrites exisiting binary
    '''
    if not config:
        if config_path:
            config = get_config(config_path)
        else:
            logger.error('No config provided!')
            return

    sauce_config = config.saucelabs

    if not update and os.path.isdir(sauce_config.connect.path):
        logger.debug('%s already exists' % sauce_config.connect.path)
    else:
        logger.info('Downloading %s' % sauce_config.connect.url)
        download_and_extract(
            url=sauce_config.connect.url,
            path=sauce_config.connect.path
        )
        logger.info('Downloaded')

    return os.path.abspath(sauce_config.connect.path)
Exemple #2
0
def get_chromedriver(config=None, config_path=None, update=False):
    '''
    Downloads chromedriver binary into **config.selenium.chromedriver.file**
    path

    :param pymlconf.ConfigManager config: configuration object
    :param update: - (optional) if True overwrites existing binary
    '''
    if not config:
        if config_path:
            config = get_config(config_path)
        else:
            logger.error('No config provided!')
            return

    chromedriver_config = config.selenium.chromedriver
    if not update and os.path.isfile(chromedriver_config.file):
        logger.debug('%s already exists' % chromedriver_config.file)
    else:
        url = None
        if platform.system() in ('Windows', ):
            url = chromedriver_config.url + chromedriver_config.zips['win']
        elif platform.system() in ('Mac', 'Darwin'):
            url = chromedriver_config.url + chromedriver_config.zips['mac']
        elif platform.system() in ('Linux'):
            if platform.architecture()[0] == '32bit':
                url = chromedriver_config.url +\
                    chromedriver_config.zips['linux32']
            if platform.architecture()[0] == '64bit':
                url = chromedriver_config.url +\
                    chromedriver_config.zips['linux64']

        if not url:
            raise Exception('Architecture is not detected')

        logger.info('Downloading %s' % url)
        download_and_unzip(url,
                           'chromedriver',
                           chromedriver_config.file)
        logger.info('Downloaded')

    return os.path.abspath(chromedriver_config.file)