def test_obtain_should_recognize_auth_info_in_url(call_subprocess_mock):
    env = reset_env()
    svn = Subversion(url='svn+http://username:[email protected]/')
    svn.obtain(env.scratch_path/'test')
    call_subprocess_mock.assert_called_with([
        svn.cmd, 'checkout', '-q', '--username', 'username', '--password', 'password',
        'http://*****:*****@svn.example.com/', env.scratch_path/'test'])
def test_export_should_recognize_auth_info_in_url(call_subprocess_mock):
    env = reset_env()
    svn = Subversion(url='svn+http://username:[email protected]/')
    svn.export(env.scratch_path/'test')
    assert call_subprocess_mock.call_args[0] == ([
        svn.cmd, 'export', '--username', 'username', '--password', 'password',
        'http://*****:*****@svn.example.com/', env.scratch_path/'test'],)
Beispiel #3
0
def test_export_should_recognize_auth_info_in_url(call_subprocess_mock):
    env = reset_env()
    svn = Subversion(url='svn+http://username:[email protected]/')
    svn.export(env.scratch_path / 'test')
    assert call_subprocess_mock.call_args[0] == ([
        svn.cmd, 'export', '--username', 'username', '--password', 'password',
        'http://*****:*****@svn.example.com/', env.scratch_path / 'test'
    ], )
def test_obtain_should_recognize_auth_info_url(call_subprocess_mock, script):
    svn = Subversion(url='svn+http://username:[email protected]/')
    svn.obtain(script.scratch_path / 'test')
    assert call_subprocess_mock.call_args[0][0] == [
        svn.name, 'checkout', '-q', '--username', 'username', '--password',
        'password', 'http://svn.example.com/',
        script.scratch_path / 'test',
    ]
Beispiel #5
0
def test_obtain_should_recognize_auth_info_url(call_subprocess_mock, script):
    svn = Subversion(url='svn+http://username:[email protected]/')
    svn.obtain(script.scratch_path / 'test')
    call_subprocess_mock.assert_called_with([
        svn.cmd, 'checkout', '-q', '--username', 'username', '--password',
        'password', 'http://*****:*****@svn.example.com/',
        script.scratch_path / 'test'
    ])
Beispiel #6
0
def unpack_file(filename, location, content_type, link):
    filename = os.path.realpath(filename)
    if (content_type == 'application/zip'
            or filename.lower().endswith(ZIP_EXTENSIONS)
            or zipfile.is_zipfile(filename)):
        unzip_file(filename, location, flatten=not filename.endswith('.whl'))
    elif (content_type == 'application/x-gzip' or tarfile.is_tarfile(filename)
          or filename.lower().endswith(TAR_EXTENSIONS + BZ2_EXTENSIONS +
                                       XZ_EXTENSIONS)):
        untar_file(filename, location)
    elif (content_type and content_type.startswith('text/html')
          and is_svn_page(file_contents(filename))):
        # We don't really care about this
        from pip.vcs.subversion import Subversion
        Subversion('svn+' + link.url).unpack(location)
    else:
        # FIXME: handle?
        # FIXME: magic signatures?
        logger.critical(
            'Cannot unpack file %s (downloaded from %s, content-type: %s); '
            'cannot detect archive format',
            filename,
            location,
            content_type,
        )
        raise InstallationError('Cannot determine archive format of %s' %
                                location)
Beispiel #7
0
def unpack_file(filename, location, content_type, link):
    filename = os.path.realpath(filename)
    if (content_type == 'application/zip' or filename.endswith('.zip')
            or filename.endswith('.pybundle') or filename.endswith('.whl')
            or zipfile.is_zipfile(filename)):
        unzip_file(filename,
                   location,
                   flatten=not filename.endswith(('.pybundle', '.whl')))
    elif (content_type == 'application/x-gzip' or tarfile.is_tarfile(filename)
          or splitext(filename)[1].lower()
          in ('.tar', '.tar.gz', '.tar.bz2', '.tgz', '.tbz')):
        untar_file(filename, location)
    elif (content_type and content_type.startswith('text/html')
          and is_svn_page(file_contents(filename))):
        # We don't really care about this
        from pip.vcs.subversion import Subversion
        Subversion('svn+' + link.url).unpack(location)
    else:
        # FIXME: handle?
        # FIXME: magic signatures?
        logger.fatal(
            'Cannot unpack file %s (downloaded from %s, content-type: %s); '
            'cannot detect archive format' %
            (filename, location, content_type))
        raise InstallationError('Cannot determine archive format of %s' %
                                location)
Beispiel #8
0
def test_subversion_remove_auth_from_url():
    # Check that the url is doctored appropriately to remove auth elements
    #    from the url
    svn_auth_url = 'https://*****:*****@svnrepo.org/svn/project/tags/v0.2'
    expected_url = 'https://svnrepo.org/svn/project/tags/v0.2'
    url = Subversion.remove_auth_from_url(svn_auth_url)
    assert url == expected_url

    # Check that this doesn't impact urls without authentication'
    svn_noauth_url = 'https://svnrepo.org/svn/project/tags/v0.2'
    expected_url = svn_noauth_url
    url = Subversion.remove_auth_from_url(svn_noauth_url)
    assert url == expected_url

    # Check that links to specific revisions are handled properly
    svn_rev_url = 'https://*****:*****@svnrepo.org/svn/project/trunk@8181'
    expected_url = 'https://svnrepo.org/svn/project/trunk@8181'
    url = Subversion.remove_auth_from_url(svn_rev_url)
    assert url == expected_url

    svn_rev_url = 'https://svnrepo.org/svn/project/trunk@8181'
    expected_url = 'https://svnrepo.org/svn/project/trunk@8181'
    url = Subversion.remove_auth_from_url(svn_rev_url)
    assert url == expected_url
Beispiel #9
0
def test_subversion_remove_auth_from_url():
    # Check that the url is doctored appropriately to remove auth elements
    #    from the url
    svn_auth_url = 'https://*****:*****@svnrepo.org/svn/project/tags/v0.2'
    expected_url = 'https://svnrepo.org/svn/project/tags/v0.2'
    url = Subversion.remove_auth_from_url(svn_auth_url)
    assert url == expected_url

    # Check that this doesn't impact urls without authentication'
    svn_noauth_url = 'https://svnrepo.org/svn/project/tags/v0.2'
    expected_url = svn_noauth_url
    url = Subversion.remove_auth_from_url(svn_noauth_url)
    assert url == expected_url

    # Check that links to specific revisions are handled properly
    svn_rev_url = 'https://*****:*****@svnrepo.org/svn/project/trunk@8181'
    expected_url = 'https://svnrepo.org/svn/project/trunk@8181'
    url = Subversion.remove_auth_from_url(svn_rev_url)
    assert url == expected_url

    svn_rev_url = 'https://svnrepo.org/svn/project/trunk@8181'
    expected_url = 'https://svnrepo.org/svn/project/trunk@8181'
    url = Subversion.remove_auth_from_url(svn_rev_url)
    assert url == expected_url
Beispiel #10
0
                '.tar', '.tar.gz', '.tar.bz2', '.tgz', '.tbz')):
        untar_file(filename, location)
    elif (content_type and content_type.startswith('text/html') and
            is_svn_page(file_contents(filename))):
=======
    elif (content_type == 'application/x-gzip'
            or tarfile.is_tarfile(filename)
            or splitext(filename)[1].lower() in (
                '.tar', '.tar.gz', '.tar.bz2', '.tgz', '.tbz')):
        untar_file(filename, location)
    elif (content_type and content_type.startswith('text/html')
            and is_svn_page(file_contents(filename))):
>>>>>>> bde4533e29dfedadf6bcf9d451baa615bc828a59
        # We don't really care about this
        from pip.vcs.subversion import Subversion
        Subversion('svn+' + link.url).unpack(location)
    else:
        # FIXME: handle?
        # FIXME: magic signatures?
        logger.critical(
            'Cannot unpack file %s (downloaded from %s, content-type: %s); '
            'cannot detect archive format',
            filename, location, content_type,
        )
        raise InstallationError(
            'Cannot determine archive format of %s' % location
        )


def remove_tracebacks(output):
    pattern = (r'(?:\W+File "(?:.*)", line (?:.*)\W+(?:.*)\W+\^\W+)?'