Пример #1
0
def load_bundle_from_cache(cache_dir, uri):
    # When the supplied uri points to a local file, don't load from cache so file can be used as is.
    if is_local_file(uri):
        return False, None, None
    else:
        log = logging.getLogger(__name__)
        try:
            urn, org, repo, package_name, tag, digest = bundle_shorthand.parse_bundle(
                uri)
            log.info(
                log_message('Loading bundle from cache', org, repo,
                            package_name, tag, digest))
            bintray_auth = load_bintray_credentials(raise_error=False)
            resolved_version = bintray_resolve_version(bintray_auth, org, repo,
                                                       package_name, tag,
                                                       digest)
            if resolved_version:
                return uri_resolver.load_bundle_from_cache(
                    cache_dir, resolved_version['download_url'])
            else:
                return False, None, None
        except MalformedBundleUriError:
            return False, None, None
        except HTTPError as http_error:
            return handle_http_error(http_error, org, repo)
        except ConnectionError:
            return False, None, None
 def test_no_repos_and_tag_with_hyphens(self):
     uri = 'reactive-maps-frontend:my-tag-with-hyphens-023f9da22'
     expected_result = ('urn:x-bundle:',
                        'typesafe', 'bundle', 'reactive-maps-frontend',
                        'my-tag-with-hyphens', '023f9da22')
     result = bundle_shorthand.parse_bundle(uri)
     self.assertEqual(expected_result, result)
 def test_full_address(self):
     uri = 'urn:x-bundle:typesafe/bundle/reactive-maps-frontend:1.0.0-023f9da22'
     expected_result = ('urn:x-bundle:',
                        'typesafe', 'bundle', 'reactive-maps-frontend',
                        '1.0.0', '023f9da22')
     result = bundle_shorthand.parse_bundle(uri)
     self.assertEqual(expected_result, result)
Пример #4
0
 def test_full_address(self):
     uri = 'urn:x-bundle:typesafe/bundle/reactive-maps-frontend:v1-023f9da22'
     expected_result = ('urn:x-bundle:',
                        'typesafe', 'bundle', 'reactive-maps-frontend',
                        'v1', '023f9da22')
     result = bundle_shorthand.parse_bundle(uri)
     self.assertEqual(expected_result, result)
Пример #5
0
def resolve_bundle(cache_dir, uri):
    log = logging.getLogger(__name__)
    try:
        urn, org, repo, package_name, compatibility_version, digest = bundle_shorthand.parse_bundle(uri)
        log.info(log_message('Resolving bundle', org, repo, package_name, compatibility_version, digest))
        return bintray_download(cache_dir, org, repo, package_name, compatibility_version, digest)
    except MalformedBundleUriError:
        return False, None, None
    except HTTPError:
        return False, None, None
Пример #6
0
def resolve_bundle_version(uri):
    log = logging.getLogger(__name__)
    try:
        bintray_username, bintray_password = load_bintray_credentials()
        urn, org, repo, package_name, compatibility_version, digest = bundle_shorthand.parse_bundle(uri)
        log.info(log_message('Resolving bundle version', org, repo, package_name, compatibility_version, digest))
        resolved_version = bintray_resolve_version(bintray_username, bintray_password, org, repo, package_name,
                                                   compatibility_version, digest)
        return resolved_version if resolved_version else None
    except MalformedBundleUriError:
        return None
    except HTTPError:
        return None
Пример #7
0
def load_bundle_from_cache(cache_dir, uri):
    # When the supplied uri points to a local file, don't load from cache so file can be used as is.
    if is_local_file(uri):
        return False, None, None
    else:
        log = logging.getLogger(__name__)
        try:
            urn, org, repo, package_name, compatibility_version, digest = bundle_shorthand.parse_bundle(uri)
            log.info(log_message('Loading bundle from cache', org, repo, package_name, compatibility_version, digest))
            bundle_download_url, auth = bintray_download_details(org, repo, package_name, compatibility_version, digest)
            if bundle_download_url:
                return uri_resolver.load_bundle_from_cache(cache_dir, bundle_download_url)
            else:
                return False, None, None
        except MalformedBundleUriError:
            return False, None, None
        except HTTPError:
            return False, None, None
Пример #8
0
def resolve_bundle(cache_dir, uri):
    log = logging.getLogger(__name__)
    try:
        urn, org, repo, package_name, tag, digest = bundle_shorthand.parse_bundle(
            uri)
        log.info(
            log_message('Resolving bundle', org, repo, package_name, tag,
                        digest))

        bintray_auth = load_bintray_credentials(raise_error=False)
        resolved_version = bintray_resolve_version(bintray_auth, org, repo,
                                                   package_name, tag, digest)
        return bintray_download_artefact(cache_dir, resolved_version,
                                         bintray_auth)
    except MalformedBundleUriError:
        return False, None, None
    except HTTPError as http_error:
        return handle_http_error(http_error, org, repo)
    except ConnectionError:
        return False, None, None
Пример #9
0
def resolve_bundle_version(uri):
    log = logging.getLogger(__name__)
    try:
        bintray_auth = load_bintray_credentials(raise_error=False)
        urn, org, repo, package_name, tag, digest = bundle_shorthand.parse_bundle(
            uri)
        log.info(
            log_message('Resolving bundle version', org, repo, package_name,
                        tag, digest))
        resolved_version = bintray_resolve_version(bintray_auth,
                                                   org,
                                                   repo,
                                                   package_name,
                                                   tag=tag,
                                                   digest=digest)
        return resolved_version if resolved_version else None
    except MalformedBundleUriError:
        return None
    except HTTPError:
        return None
    except ConnectionError:
        return None
Пример #10
0
 def test_bundle_name_only(self):
     uri = 'reactive-maps-frontend'
     expected_result = ('urn:x-bundle:', 'typesafe', 'bundle', 'reactive-maps-frontend', None, None)
     result = bundle_shorthand.parse_bundle(uri)
     self.assertEqual(expected_result, result)
Пример #11
0
 def test_no_digest(self):
     uri = 'reactive-maps-frontend:1.0.0'
     expected_result = ('urn:x-bundle:', 'typesafe', 'bundle', 'reactive-maps-frontend', '1.0.0', None)
     result = bundle_shorthand.parse_bundle(uri)
     self.assertEqual(expected_result, result)
Пример #12
0
 def test_no_repos(self):
     uri = 'reactive-maps-frontend:v1-023f9da22'
     expected_result = ('urn:x-bundle:', 'typesafe', 'bundle',
                        'reactive-maps-frontend', 'v1', '023f9da22')
     result = bundle_shorthand.parse_bundle(uri)
     self.assertEqual(expected_result, result)
Пример #13
0
 def test_bundle_name_only(self):
     uri = 'reactive-maps-frontend'
     expected_result = ('urn:x-bundle:', 'typesafe', 'bundle', 'reactive-maps-frontend', None, None)
     result = bundle_shorthand.parse_bundle(uri)
     self.assertEqual(expected_result, result)