def _pager_file(savepath):

        if os.path.splitext(savepath)[1].upper() in ('.HTM', '.HTML'):
            pagers = ('w3m', 'links', 'lynx', 'less', 'more')
        else:
            pagers = ('less', 'more')

        file_showed = False
        for pager in pagers:
            cmd = "%s %s" % (pager, savepath)
            try:
                os.system(cmd)
            except OSError:
                continue
            else:
                file_showed = True
                break

        if not file_showed:
            f = open(savepath)
            msger.raw(f.read())
            f.close()
            msger.pause()
Beispiel #2
0
    def _pager_file(savepath):

        if os.path.splitext(savepath)[1].upper() in ('.HTM', '.HTML'):
            pagers = ('w3m', 'links', 'lynx', 'less', 'more')
        else:
            pagers = ('less', 'more')

        file_showed = False
        for pager in pagers:
            cmd = "%s %s" % (pager, savepath)
            try:
                os.system(cmd)
            except OSError:
                continue
            else:
                file_showed = True
                break

        if not file_showed:
            f = open(savepath)
            msger.raw(f.read())
            f.close()
            msger.pause()
                                os.path.join(repo_lic_dir, repo.id + '_LICENSE.txt'))
        if repo_eula_path:
            # found
            baseurl = url
            break

    if not baseurl:
        shutil.rmtree(repo_lic_dir) #cleanup
        return True

    # show the license file
    msger.info('For the software packages in this yum repo:')
    msger.info('    %s: %s' % (name, baseurl))
    msger.info('There is an "End User License Agreement" file that need to be checked.')
    msger.info('Please read the terms and conditions outlined in it and answer the followed qustions.')
    msger.pause()

    _pager_file(repo_eula_path)

    # Asking for the "Accept/Decline"
    if not msger.ask('Would you agree to the terms and conditions outlined in the above End User License Agreement?'):
        msger.warning('Will not install pkgs from this repo.')
        shutil.rmtree(repo_lic_dir) #cleanup
        return False

    # try to find support_info.html for extra infomation
    repo_info_url = urlparse.urljoin(baseurl, "support_info.html")
    repo_info_path = _check_and_download_url(
                            u2opener,
                            repo_info_url,
                            os.path.join(repo_lic_dir, repo.id + '_support_info.html'))
Beispiel #4
0
            baseurl = url
            break

    if not baseurl:
        return True

    # show the license file
    msger.info('For the software packages in this yum repo:')
    msger.info('    %s: %s' % (name, baseurl))
    msger.info(
        'There is an "End User License Agreement" file that need to be checked.'
    )
    msger.info(
        'Please read the terms and conditions outlined in it and answer the followed qustions.'
    )
    msger.pause()

    _pager_file(repo_eula_path)

    # Asking for the "Accept/Decline"
    if not msger.ask(
            'Would you agree to the terms and conditions outlined in the above End User License Agreement?'
    ):
        msger.warning('Will not install pkgs from this repo.')
        shutil.rmtree(repo_lic_dir)  #cleanup
        return False

    # try to find support_info.html for extra infomation
    repo_info_url = urlparse.urljoin(baseurl, "support_info.html")
    repo_info_path = _check_and_download_url(
        u2opener, repo_info_url,
Beispiel #5
0
def checkRepositoryEULA(name, repo):
    """ This function is to check the EULA file if provided.
        return True: no EULA or accepted
        return False: user declined the EULA
    """
    proxies = {}
    proxy = repo.proxy

    if proxy:
        proxy_username = repo.proxy_username
        proxy_password = repo.proxy_password

        if proxy_username:
            proxy_netloc = urlparse.urlsplit(proxy).netloc
            if proxy_password:
                proxy = 'http://%s:%s@%s' % (proxy_username, proxy_password, proxy_netloc)
            else:
                proxy = 'http://%s@%s' % (proxy_username, proxy_netloc)

    else:
        proxy = get_proxy_for(repo.baseurl[0])

    if proxy:
        proxies = {str(repo.baseurl[0].split(':')[0]): str(proxy)}

    # download all remote files to one temp dir
    baseurl = None
    repo_lic_dir = tempfile.mkdtemp(prefix = 'repolic')

    for url in repo.baseurl:

        # try to download
        repo_eula_url = urlparse.urljoin(url, "LICENSE.txt")

        repo_eula_path = myurlgrab(repo_eula_url,
                                   os.path.join(repo_lic_dir, repo.id + '_LICENSE.txt'),
                                   proxies, ignore_404 = True)
        if repo_eula_path:
            # found
            baseurl = url
            break

    if not baseurl:
        shutil.rmtree(repo_lic_dir) #cleanup
        return True

    # show the license file
    msger.info('For the software packages in this yum repo:')
    msger.info('    %s: %s' % (name, baseurl))
    msger.info('There is an "End User License Agreement" file that need to be checked.')
    msger.info('Please read the terms and conditions outlined in it and answer the followed qustions.')
    msger.pause()

    _pager_file(repo_eula_path)

    # Asking for the "Accept/Decline"
    if not msger.ask('Would you agree to the terms and conditions outlined in the above End User License Agreement?'):
        msger.warning('Will not install pkgs from this repo.')
        shutil.rmtree(repo_lic_dir) #cleanup
        return False

    # try to find support_info.html for extra infomation
    repo_info_url = urlparse.urljoin(baseurl, "support_info.html")
    repo_info_path = myurlgrab(repo_eula_url,
                               os.path.join(repo_lic_dir, repo.id + '_LICENSE.txt'),
                               proxies, ignore_404 = True)
    if repo_info_path:
        msger.info('There is one more file in the repo for additional support information, please read it')
        msger.pause()
        _pager_file(repo_info_path)

    #cleanup
    shutil.rmtree(repo_lic_dir)
    return True
Beispiel #6
0
def checkRepositoryEULA(name, repo):
    """ This function is to check the EULA file if provided.
        return True: no EULA or accepted
        return False: user declined the EULA
    """
    proxies = {}
    proxy = repo.proxy

    if proxy:
        proxy_username = repo.proxy_username
        proxy_password = repo.proxy_password

        if proxy_username:
            proxy_netloc = urllib.parse.urlsplit(proxy).netloc
            if proxy_password:
                proxy = 'http://%s:%s@%s' % (proxy_username, proxy_password,
                                             proxy_netloc)
            else:
                proxy = 'http://%s@%s' % (proxy_username, proxy_netloc)

    else:
        proxy = get_proxy_for(repo.baseurl[0])

    if proxy:
        proxies = {str(repo.baseurl[0].split(':')[0]): str(proxy)}

    # download all remote files to one temp dir
    baseurl = None
    repo_lic_dir = tempfile.mkdtemp(prefix='repolic')

    for url in repo.baseurl:

        # try to download
        repo_eula_url = urllib.parse.urljoin(url, "LICENSE.txt")

        repo_eula_path = myurlgrab(repo_eula_url,
                                   os.path.join(repo_lic_dir,
                                                repo.id + '_LICENSE.txt'),
                                   proxies,
                                   ignore_404=True)
        if repo_eula_path:
            # found
            baseurl = url
            break

    if not baseurl:
        shutil.rmtree(repo_lic_dir)  #cleanup
        return True

    # show the license file
    msger.info('For the software packages in this yum repo:')
    msger.info('    %s: %s' % (name, baseurl))
    msger.info(
        'There is an "End User License Agreement" file that need to be checked.'
    )
    msger.info(
        'Please read the terms and conditions outlined in it and answer the followed qustions.'
    )
    msger.pause()

    _pager_file(repo_eula_path)

    # Asking for the "Accept/Decline"
    if not msger.ask(
            'Would you agree to the terms and conditions outlined in the above End User License Agreement?'
    ):
        msger.warning('Will not install pkgs from this repo.')
        shutil.rmtree(repo_lic_dir)  #cleanup
        return False

    # try to find support_info.html for extra infomation
    repo_info_url = urllib.parse.urljoin(baseurl, "support_info.html")
    repo_info_path = myurlgrab(repo_eula_url,
                               os.path.join(repo_lic_dir,
                                            repo.id + '_LICENSE.txt'),
                               proxies,
                               ignore_404=True)
    if repo_info_path:
        msger.info(
            'There is one more file in the repo for additional support information, please read it'
        )
        msger.pause()
        _pager_file(repo_info_path)

    #cleanup
    shutil.rmtree(repo_lic_dir)
    return True