depot.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:solaris-ips 作者: oracle 项目源码 文件源码
def catalog_1(self, *tokens):
                """Outputs the contents of the specified catalog file, using the
                name in the request path, directly to the client."""

                try:
                        name = tokens[0]
                except IndexError:
                        raise cherrypy.HTTPError(http_client.FORBIDDEN,
                            _("Directory listing not allowed."))

                try:
                        fpath = self.repo.catalog_1(name,
                            pub=self._get_req_pub())
                except srepo.RepositoryError as e:
                        # Treat any remaining repository error as a 404, but
                        # log the error and include the real failure
                        # information.
                        cherrypy.log("Request failed: {0}".format(str(e)))
                        raise cherrypy.HTTPError(http_client.NOT_FOUND, str(e))

                # NASTY
                # Stash catalog entry for later use.
                # Toss out the list if it's larger than 1024 items.
                if len(self.requested_catalogs) > 1024:
                        self.requested_catalogs = [fpath]
                else:
                        self.requested_catalogs.append(fpath)

                # NASTY
                # Send the wrong catalog
                if self.need_nasty_3():
                        cherrypy.log("NASTY catalog_1: wrong catalog file")
                        badpath = random.choice(self.requested_catalogs)
                        return serve_file(badpath, "text/plain; charset=utf-8")

                # NASTY
                return self.nasty_serve_file(fpath, "text/plain; charset=utf-8")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号