예제 #1
0
    def one(self, id):
        try:
            try:
                id = int(id)
            except ValueError:
                abort(404, 'No such log')

            set_expires(int(config['app_conf']['expires.removal.one']))

            removal = g.shm.removal_get_one(self._db(), id)
            files = g.shm.removal_get_affected(self._db(), id)

            fileinfo = {}
            for hash in files:
                fileinfo[hash] = g.shm.packages_get_file_info(self._db(), hash)
            for hash in fileinfo:
                fileinfo[hash] = map(lambda fi: dict(fi), fileinfo[hash])
                for fi in fileinfo[hash]:
                    fi['dirlink'] = build_url_archive(fi['archive_name'], fi['run'], fi['path'])
                    fi['link'] = build_url_archive(fi['archive_name'], fi['run'], os.path.join(fi['path'], fi['name']), isadir=False )

            files.sort(key=lambda a: (fileinfo[a][0]['name'], a)) # reproducible file order

            c.removal = removal
            c.files = files
            c.fileinfo = fileinfo
            c.breadcrumbs = self._build_crumbs(id)
            c.title = 'Removal log #%d'%(id)
            return render('/removal-list-one.mako')
        finally:
            self._db_close()
예제 #2
0
    def binary(self, binary):
        self._ensure_ascii(binary)
        try:

            #etag_cache( app_globals.shm.packages_get_etag(self._db()) )
            set_expires(int(config['app_conf']['expires.package.source']))

            binaryversions = app_globals.shm.packages_get_binary_versions_by_name(self._db(), binary)

            if len(binaryversions) == 0:
                abort(404, 'No such binary package')

            binaryversions = map(lambda b: dict(b), binaryversions)
            for b in binaryversions:
                b['link'] = url_quote('../../package/%s/%s/'%(b['source'], b['version']))
                b['escaped_name'] = self._attribute_escape(b['name'])
                b['escaped_binary_version'] = self._attribute_escape(b['binary_version'])

            c.binary = binary
            c.binaryversions = binaryversions
            c.breadcrumbs = self._build_crumbs(binary, is_binary=True)
            c.title = binary
            return render('/package-binary.mako')
        finally:
            self._db_close()
예제 #3
0
    def root(self):
        try:
            set_expires(int(config['app_conf']['expires.removal']))
            removals = g.shm.removal_get_list(self._db())

            c.removals = removals
            c.breadcrumbs = self._build_crumbs()
            return render('/removal-list.mako')
        finally:
            self._db_close()
예제 #4
0
 def index(self):
     db = None
     try:
         db = DBInstance(app_globals.pool)
         c.names = link_quote_array(app_globals.shm.archives_get_list(db))
         c.srcstarts = link_quote_array(app_globals.shm.packages_get_name_starts(db))
         c.binstarts = link_quote_array(app_globals.shm.packages_get_name_starts(db, get_binary=True))
         set_expires(int(config['app_conf']['expires.root']))
         return render('/root.mako')
     finally:
         if not db is None: db.close()
예제 #5
0
    def source(self, source):
        self._ensure_ascii(source)
        try:
            #etag_cache( app_globals.shm.packages_get_etag(self._db()) )
            set_expires(int(config['app_conf']['expires.package.source']))

            sourceversions = app_globals.shm.packages_get_source_versions(self._db(), source)

            if len(sourceversions) == 0:
                abort(404, 'No such source package')

            c.src = source
            c.sourceversions = link_quote_array(sourceversions)
            c.breadcrumbs = self._build_crumbs(source)
            c.title = source
            return render('/package-source.mako')
        finally:
            self._db_close()
예제 #6
0
    def source_version(self, source, version):
        self._ensure_ascii(source)
        self._ensure_ascii(version)
        try:
            #etag_cache( app_globals.shm.packages_get_etag(self._db()) )
            set_expires(int(config['app_conf']['expires.package.source_version']))

            sourcefiles = app_globals.shm.packages_get_source_files(self._db(), source, version)
            binpkgs = app_globals.shm.packages_get_binpkgs_from_source(self._db(), source, version)

            # we may have binaries without sources.
            if len(sourcefiles) == 0 and len(binpkgs) == 0:
                abort(404, 'No source or binary packages found')

            binpkgs = map(lambda b: dict(b), binpkgs)
            binhashes = []
            for binpkg in binpkgs:
                binpkg['escaped_name'] = self._attribute_escape(binpkg['name'])
                binpkg['escaped_version'] = self._attribute_escape(binpkg['version'])
                binpkg['files'] = map(lambda x: x['hash'], app_globals.shm.packages_get_binary_files_from_id(self._db(), binpkg['binpkg_id']))
                binhashes += binpkg['files']

            fileinfo = {}
            for hash in sourcefiles + binhashes:
                fileinfo[hash] = app_globals.shm.packages_get_file_info(self._db(), hash)
            for hash in fileinfo:
                fileinfo[hash] = map(lambda fi: dict(fi), fileinfo[hash])
                for fi in fileinfo[hash]:
                    fi['dirlink'] = build_url_archive(fi['archive_name'], fi['run'], fi['path'])
                    fi['link'] = build_url_archive(fi['archive_name'], fi['run'], os.path.join(fi['path'], fi['name']), isadir=False )

            sourcefiles.sort(key=lambda a: (fileinfo[a][0]['name'], a) if len(fileinfo[a]) > 0 else (None,a)) # reproducible file order

            c.src = source
            c.version = version
            c.sourcefiles = sourcefiles
            c.binpkgs = binpkgs
            c.fileinfo = fileinfo
            c.breadcrumbs = self._build_crumbs(source, version)
            c.title = '%s (%s)'%(source, version)
            return render('/package-source-one.mako')
        finally:
            self._db_close()
예제 #7
0
    def document(self):
        """Render the error document"""
        resp = request.environ.get("pylons.original_response")
        content = literal(resp.body) or cgi.escape(request.GET.get("message", ""))

        if config["debug"]:
            page = error_document_template % dict(
                prefix=request.environ.get("SCRIPT_NAME", ""),
                code=cgi.escape(request.GET.get("code", str(resp.status_int))),
                message=content,
            )
            return page
        else:
            c.code = cgi.escape(request.GET.get("code", str(resp.status_int)))
            c.title = "Error %s" % (c.code)
            c.content = content
            if resp and c.code == "404":
                response.expires = resp.expires
                response.cache_control = resp.cache_control
                response.pragma = resp.pragma
            return render("/error.mako")
예제 #8
0
    def archive_base(self, archive):
        try:
            #etag_cache( app_globals.shm.mirrorruns_get_etag(self._db(), archive) )
            set_expires(int(config['app_conf']['expires.archive.index']))

            if 'year' in request.params and 'month' in request.params:
                y = request.params['year']
                m = request.params['month']
                return self._archive_ym(archive, y, m)

            yearmonths = app_globals.shm.mirrorruns_get_yearmonths_from_archive(self._db(), archive)

            if yearmonths is None:
                abort(404, 'Archive "%s" does not exist'%(archive))

            c.yearmonths = yearmonths
            c.archive = archive
            c.breadcrumbs = self._build_crumbs(archive)
            c.title = archive
            return render('/archive.mako')
        finally:
            self._db_close()
예제 #9
0
    def _archive_ym(self, archive, year, month):
        if not re.match('\d{4}$', year): # match matches only at start of string
            abort(404, 'Year "%s" is not valid.'%(year))
        if not re.match('\d{1,2}$', month): # match matches only at start of string
            abort(404, 'Month "%s" is not valid.'%(month))

        runs = app_globals.shm.mirrorruns_get_runs_from_archive_ym(self._db(), archive, year, month)
        if runs is None:
            abort(404, 'Archive "%s" does not exist'%(archive))
        if len(runs) == 0:
            abort(404, 'Found no mirrorruns for archive %s in %s-%s.'%(archive, year, month))

        c.archive = archive
        c.year = year
        c.month = "%02d"%(int(month))
        c.breadcrumbs = self._build_crumbs(archive, year=int(year), month=int(month))
        c.runs = map(lambda r:
                        { 'run'   : r['run'],
                          # make a machine readable version of a timestamp
                          'run_mr': rfc3339_timestamp(r['run'])
                        }, runs)
        c.title = '%s:%s-%02d'%(archive, year, int(month))
        return render('/archive-runs.mako')
예제 #10
0
    def _dir_helper(self, archive, run, stat):
        realpath = os.path.join('/archive', archive, rfc3339_timestamp(run['run']), stat['path'].strip('/'), '')
        if realpath != request.environ['PATH_INFO']:
            request.environ['PATH_INFO'] = realpath
            url = construct_url(request.environ)
            raise HTTPMovedPermanently(url)

        list = app_globals.shm.mirrorruns_readdir(self._db(), run['mirrorrun_id'], stat['path'])
        list = map(lambda b: dict(b), list)
        for e in list:
            e['quoted_name'] = urllib.quote(e['name'])
            if not e['target'] is None:
                e['quoted_target'] = urllib.quote(e['target'])
        if stat['path'] != '/':
            list = [ { 'filetype': 'd', 'name': '..', 'quoted_name': '..', 'first_run': None, 'last_run': None } ] + list

        node_info = app_globals.shm.mirrorruns_get_first_last_from_node(self._db(), stat['node_id'])
        neighbors = app_globals.shm.mirrorruns_get_neighbors(self._db(), run['mirrorrun_id'])
        neighbors_change = app_globals.shm.mirrorruns_get_neighbors_change(self._db(), run['archive_id'], run['run'], stat['directory_id']) 

        c.run = run
        c.readdir = list
        c.nav = {
          'first':       node_info['first_run'],
          'prev_change': neighbors_change['prev'],
          'prev':        neighbors['prev'],
          'next':        neighbors['next'],
          'next_change': neighbors_change['next'],
          'last':        node_info['last_run'] }

        for key in c.nav.keys():
            if not c.nav[key] is None:
                c.nav[key+'_link'] = os.path.join('/archive', archive, rfc3339_timestamp(c.nav[key]), stat['path'].strip('/'), '')

        c.breadcrumbs = self._build_crumbs(archive, run, stat['path'])
        c.title = '%s:%s (%s)'%(archive, stat['path'], run['run'])
        return render('/archive-dir.mako')
예제 #11
0
    def root(self):
        if 'src' in request.params:
            set_expires(int(config['app_conf']['expires.package.root_cat']))
            url = url_quote(request.params['src'] + "/")
            return redirect(url)
        elif 'cat' in request.params:
            try:
                #etag_cache( app_globals.shm.packages_get_etag(self._db()) )
                set_expires(int(config['app_conf']['expires.package.root_cat']))

                start = request.params['cat']
                pkgs = app_globals.shm.packages_get_name_starts_with(self._db(), start)
                if pkgs is None:
                    abort(404, 'No source packages in this category.')
                c.start = start
                c.packages = link_quote_array(pkgs)
                c.breadcrumbs = self._build_crumbs(start=start)
                c.title = '%s*'%(start)
                return render('/package-list-packages.mako')
            finally:
                self._db_close()
        else:
            set_expires(int(config['app_conf']['expires.package.root_cat']))
            return redirect("../")
예제 #12
0
 def oldnews(self):
     set_expires(int(config['app_conf']['expires.root']))
     c.breadcrumbs = self._build_crumbs('older news')
     return render('/misc-oldnews.mako')