⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseweb.py

📁 The BuildBot is a system to automate the compile/test cycle required by most software projects. CVS
💻 PY
📖 第 1 页 / 共 2 页
字号:
     /builders/_all/{force,stop}: force a build/stop building on all builders.     /changes : summarize all ChangeSources     /changes/CHANGENUM: a page describing a single Change     /schedulers/SCHEDULERNAME: a page describing a Scheduler, including                                a description of its behavior, a list of the                                Builders it triggers, and list of the Changes                                that are queued awaiting the tree-stable                                timer, and controls to accelerate the timer.     /buildslaves : list all BuildSlaves     /buildslaves/SLAVENAME : describe a single BuildSlave     /one_line_per_build : summarize the last few builds, one line each     /one_line_per_build/BUILDERNAME : same, but only for a single builder     /one_box_per_builder : show the latest build and current activity     /about : describe this buildmaster (Buildbot and support library versions)     /xmlrpc : (not yet implemented) an XMLRPC server with build status    All URLs for pages which are not defined here are used to look    for files in PUBLIC_HTML, which defaults to BASEDIR/public_html.    This means that /robots.txt or /buildbot.css or /favicon.ico can    be placed in that directory.    If an index file (index.html, index.htm, or index, in that order) is    present in PUBLIC_HTML, it will be used for the root resource. If not,    the default behavior is to put a redirection to the /waterfall page.    All of the resources provided by this service use relative URLs to reach    each other. The only absolute links are the c['projectURL'] links at the    top and bottom of the page, and the buildbot home-page link at the    bottom.    This webserver defines class attributes on elements so they can be styled    with CSS stylesheets. All pages pull in PUBLIC_HTML/buildbot.css, and you    can cause additional stylesheets to be loaded by adding a suitable <link>    to the WebStatus instance's .head_elements attribute.    Buildbot uses some generic classes to identify the type of object, and    some more specific classes for the various kinds of those types. It does    this by specifying both in the class attributes where applicable,    separated by a space. It is important that in your CSS you declare the    more generic class styles above the more specific ones. For example,    first define a style for .Event, and below that for .SUCCESS    The following CSS class names are used:        - Activity, Event, BuildStep, LastBuild: general classes        - waiting, interlocked, building, offline, idle: Activity states        - start, running, success, failure, warnings, skipped, exception:          LastBuild and BuildStep states        - Change: box with change        - Builder: box for builder name (at top)        - Project        - Time    """    # we are not a ComparableMixin, and therefore the webserver will be    # rebuilt every time we reconfig. This is because WebStatus.putChild()    # makes it too difficult to tell whether two instances are the same or    # not (we'd have to do a recursive traversal of all children to discover    # all the changes).    def __init__(self, http_port=None, distrib_port=None, allowForce=False,                       public_html="public_html", site=None):        """Run a web server that provides Buildbot status.        @type  http_port: int or L{twisted.application.strports} string        @param http_port: a strports specification describing which port the                          buildbot should use for its web server, with the                          Waterfall display as the root page. For backwards                          compatibility this can also be an int. Use                          'tcp:8000' to listen on that port, or                          'tcp:12345:interface=127.0.0.1' if you only want                          local processes to connect to it (perhaps because                          you are using an HTTP reverse proxy to make the                          buildbot available to the outside world, and do not                          want to make the raw port visible).        @type  distrib_port: int or L{twisted.application.strports} string        @param distrib_port: Use this if you want to publish the Waterfall                             page using web.distrib instead. The most common                             case is to provide a string that is an absolute                             pathname to the unix socket on which the                             publisher should listen                             (C{os.path.expanduser(~/.twistd-web-pb)} will                             match the default settings of a standard                             twisted.web 'personal web server'). Another                             possibility is to pass an integer, which means                             the publisher should listen on a TCP socket,                             allowing the web server to be on a different                             machine entirely. Both forms are provided for                             backwards compatibility; the preferred form is a                             strports specification like                             'unix:/home/buildbot/.twistd-web-pb'. Providing                             a non-absolute pathname will probably confuse                             the strports parser.        @param allowForce: boolean, if True then the webserver will allow                           visitors to trigger and cancel builds        @param public_html: the path to the public_html directory for this display,                            either absolute or relative to the basedir.  The default                            is 'public_html', which selects BASEDIR/public_html.        @type site: None or L{twisted.web.server.Site}        @param site: Use this if you want to define your own object instead of                     using the default.`        """        service.MultiService.__init__(self)        if type(http_port) is int:            http_port = "tcp:%d" % http_port        self.http_port = http_port        if distrib_port is not None:            if type(distrib_port) is int:                distrib_port = "tcp:%d" % distrib_port            if distrib_port[0] in "/~.": # pathnames                distrib_port = "unix:%s" % distrib_port        self.distrib_port = distrib_port        self.allowForce = allowForce        self.public_html = public_html        # If we were given a site object, go ahead and use it.        if site:            self.site = site        else:            # this will be replaced once we've been attached to a parent (and            # thus have a basedir and can reference BASEDIR)            root = static.Data("placeholder", "text/plain")            self.site = server.Site(root)        self.childrenToBeAdded = {}        self.setupUsualPages()        # the following items are accessed by HtmlResource when it renders        # each page.        self.site.buildbot_service = self        self.header = HEADER        self.head_elements = HEAD_ELEMENTS[:]        self.body_attrs = BODY_ATTRS.copy()        self.footer = FOOTER        self.template_values = {}        # keep track of cached connections so we can break them when we shut        # down. See ticket #102 for more details.        self.channels = weakref.WeakKeyDictionary()        if self.http_port is not None:            s = strports.service(self.http_port, self.site)            s.setServiceParent(self)        if self.distrib_port is not None:            f = pb.PBServerFactory(distrib.ResourcePublisher(self.site))            s = strports.service(self.distrib_port, f)            s.setServiceParent(self)    def setupUsualPages(self):        #self.putChild("", IndexOrWaterfallRedirection())        self.putChild("waterfall", WaterfallStatusResource())        self.putChild("grid", GridStatusResource())        self.putChild("builders", BuildersResource()) # has builds/steps/logs        self.putChild("changes", ChangesResource())        self.putChild("buildslaves", BuildSlavesResource())        #self.putChild("schedulers", SchedulersResource())        self.putChild("one_line_per_build", OneLinePerBuild())        self.putChild("one_box_per_builder", OneBoxPerBuilder())        self.putChild("xmlrpc", XMLRPCServer())        self.putChild("about", AboutBuildbot())    def __repr__(self):        if self.http_port is None:            return "<WebStatus on path %s at %s>" % (self.distrib_port,                                                     hex(id(self)))        if self.distrib_port is None:            return "<WebStatus on port %s at %s>" % (self.http_port,                                                     hex(id(self)))        return ("<WebStatus on port %s and path %s at %s>" %                (self.http_port, self.distrib_port, hex(id(self))))    def setServiceParent(self, parent):        service.MultiService.setServiceParent(self, parent)        # this class keeps a *separate* link to the buildmaster, rather than        # just using self.parent, so that when we are "disowned" (and thus        # parent=None), any remaining HTTP clients of this WebStatus will still        # be able to get reasonable results.        self.master = parent        self.setupSite()    def setupSite(self):        # this is responsible for creating the root resource. It isn't done        # at __init__ time because we need to reference the parent's basedir.        htmldir = os.path.abspath(os.path.join(self.master.basedir, self.public_html))        if os.path.isdir(htmldir):            log.msg("WebStatus using (%s)" % htmldir)        else:            log.msg("WebStatus: warning: %s is missing. Do you need to run"                    " 'buildbot upgrade-master' on this buildmaster?" % htmldir)            # all static pages will get a 404 until upgrade-master is used to            # populate this directory. Create the directory, though, since            # otherwise we get internal server errors instead of 404s.            os.mkdir(htmldir)        root = static.File(htmldir)        for name, child_resource in self.childrenToBeAdded.iteritems():            root.putChild(name, child_resource)        status = self.getStatus()        root.putChild("rss", Rss20StatusResource(status))        root.putChild("atom", Atom10StatusResource(status))        self.site.resource = root    def putChild(self, name, child_resource):        """This behaves a lot like root.putChild() . """        self.childrenToBeAdded[name] = child_resource    def registerChannel(self, channel):        self.channels[channel] = 1 # weakrefs    def stopService(self):        for channel in self.channels:            try:                channel.transport.loseConnection()            except:                log.msg("WebStatus.stopService: error while disconnecting"                        " leftover clients")                log.err()        return service.MultiService.stopService(self)    def getStatus(self):        return self.master.getStatus()    def getControl(self):        if self.allowForce:            return IControl(self.master)        return None    def getChangeSvc(self):        return self.master.change_svc    def getPortnum(self):        # this is for the benefit of unit tests        s = list(self)[0]        return s._port.getHost().port# resources can get access to the IStatus by calling# request.site.buildbot_service.getStatus()# this is the compatibility class for the old waterfall. It is exactly like a# regular WebStatus except that the root resource (e.g. http://buildbot.net/)# always redirects to a WaterfallStatusResource, and the old arguments are# mapped into the new resource-tree approach. In the normal WebStatus, the# root resource either redirects the browser to /waterfall or serves# PUBLIC_HTML/index.html, and favicon/robots.txt are provided by# having the admin write actual files into PUBLIC_HTML/ .# note: we don't use a util.Redirect here because HTTP requires that the# Location: header provide an absolute URI, and it's non-trivial to figure# out our absolute URI from here.class Waterfall(WebStatus):    if hasattr(sys, "frozen"):        # all 'data' files are in the directory of our executable        here = os.path.dirname(sys.executable)        buildbot_icon = os.path.abspath(os.path.join(here, "buildbot.png"))        buildbot_css = os.path.abspath(os.path.join(here, "classic.css"))    else:        # running from source        # the icon is sibpath(__file__, "../buildbot.png") . This is for        # portability.        up = os.path.dirname        buildbot_icon = os.path.abspath(os.path.join(up(up(up(__file__))),                                                     "buildbot.png"))        buildbot_css = os.path.abspath(os.path.join(up(__file__),                                                    "classic.css"))    compare_attrs = ["http_port", "distrib_port", "allowForce",                     "categories", "css", "favicon", "robots_txt"]    def __init__(self, http_port=None, distrib_port=None, allowForce=True,                 categories=None, css=buildbot_css, favicon=buildbot_icon,                 robots_txt=None):        import warnings        m = ("buildbot.status.html.Waterfall is deprecated as of 0.7.6 "             "and will be removed from a future release. "             "Please use html.WebStatus instead.")        warnings.warn(m, DeprecationWarning)        WebStatus.__init__(self, http_port, distrib_port, allowForce)        self.css = css        if css:            if os.path.exists(os.path.join("public_html", "buildbot.css")):                # they've upgraded, so defer to that copy instead                pass            else:                data = open(css, "rb").read()                self.putChild("buildbot.css", static.Data(data, "text/plain"))        self.favicon = favicon        self.robots_txt = robots_txt        if favicon:            data = open(favicon, "rb").read()            self.putChild("favicon.ico", static.Data(data, "image/x-icon"))        if robots_txt:            data = open(robots_txt, "rb").read()            self.putChild("robots.txt", static.Data(data, "text/plain"))        self.putChild("", WaterfallStatusResource(categories))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -