Beispiel #1
0
def package(request, fpkgs='/find-packages'):
    """
    @@ convert to use action on a post rather than on a get
    """
    name = request.matchdict['name']
    version = request.matchdict['version']
    details = PyPi.package_details(name, version)
    flash = request.session.flash 
    if not details:
        flash("%s-%s not found" %(name, version))
        return HTTPFound(fpkgs)
        
    if details[0]['md5_digest'] in request.index_data:
        logger.debug('Package %s-%s already in index' %(name, version))
        return HTTPFound('/index/%s' %name)
            
    details = details[0]
    url = details['url']
    filename = details['filename']
    newfile = None
    try:
        resp = requests.get(url)
        newfile = request.file_root / filename
        newfile.write_bytes(resp.content)
    except HTTPError, e:
        error = "HTTP Error: %d %s - %s" %(e.code, exc.status_map[e.code].title, url)
        logger.error(error)
        flash(error)
Beispiel #2
0
 def test_details(self, sp):
     from cheeseprism.rpc import PyPi
     out = PyPi.package_details('wicked', '1.0')
     ((index, )), _ = sp.call_args
     assert index == PyPi.index
     assert sp.called
     assert out
Beispiel #3
0
def package(request, fpkgs='/find-packages'):
    """
    @@ convert to use action on a post rather than on a get
    """
    name = request.matchdict['name']
    version = request.matchdict['version']
    details = PyPi.package_details(name, version)
    flash = request.session.flash
    if not details:
        flash("%s-%s not found" % (name, version))
        return HTTPFound(fpkgs)

    if details[0]['md5_digest'] in request.index_data:
        logger.debug('Package %s-%s already in index' % (name, version))
        return HTTPFound('/index/%s' % name)

    details = details[0]
    url = details['url']
    filename = details['filename']
    newfile = None
    try:
        resp = requests.get(url)
        newfile = request.file_root / filename
        newfile.write_bytes(resp.content)
    except HTTPError, e:
        error = "HTTP Error: %d %s - %s" % (e.code,
                                            exc.status_map[e.code].title, url)
        logger.error(error)
        flash(error)
Beispiel #4
0
    def test_details(self, sp):
        from cheeseprism.rpc import PyPi

        out = PyPi.package_details("wicked", "1.0")
        ((index,)), _ = sp.call_args
        assert index == PyPi.index
        assert sp.called
        assert out