예제 #1
0
    def setupSite(self, new_config):
        self.reconfigurableResources = []

        # we're going to need at least the base plugin (buildbot-www)
        if 'base' not in self.apps:
            raise RuntimeError("could not find buildbot-www; is it installed?")

        root = self.apps.get('base').resource
        self.configPlugins(root, new_config)
        # /
        root.putChild(b'', wwwconfig.IndexResource(
            self.master, self.apps.get('base').static_dir))

        # /auth
        root.putChild(b'auth', auth.AuthRootResource(self.master))

        # /avatar
        root.putChild(b'avatar', avatar.AvatarResource(self.master))

        # /api
        root.putChild(b'api', rest.RestRootResource(self.master))

        # /ws
        root.putChild(b'ws', ws.WsResource(self.master))

        # /sse
        root.putChild(b'sse', sse.EventResource(self.master))

        # /change_hook
        resource_obj = change_hook.ChangeHookResource(master=self.master)

        # FIXME: this does not work with reconfig
        change_hook_auth = new_config.www.get('change_hook_auth')
        if change_hook_auth is not None:
            resource_obj = self.setupProtectedResource(
                resource_obj, change_hook_auth)
        root.putChild(b"change_hook", resource_obj)

        self.root = root

        rotateLength = new_config.www.get(
            'logRotateLength') or self.master.log_rotation.rotateLength
        maxRotatedFiles = new_config.www.get(
            'maxRotatedFiles') or self.master.log_rotation.maxRotatedFiles

        httplog = None
        if new_config.www['logfileName']:
            httplog = os.path.abspath(
                os.path.join(self.master.basedir, new_config.www['logfileName']))
        self.site = BuildbotSite(root, logPath=httplog, rotateLength=rotateLength,
                                 maxRotatedFiles=maxRotatedFiles)

        self.site.sessionFactory = None

        # Make sure site.master is set. It is required for poller change_hook
        self.site.master = self.master
        # convert this to a tuple so it can't be appended anymore (in
        # case some dynamically created resources try to get reconfigs)
        self.reconfigurableResources = tuple(self.reconfigurableResources)
예제 #2
0
    def setupSite(self, new_config):
        self.reconfigurableResources = []
        root = self.apps.get('base').resource
        for key, plugin in new_config.www.get('plugins', {}).items():
            if key not in self.apps:
                raise RuntimeError(
                    "could not find plugin %s; is it installed?" % (key, ))
            print "putChild", key, self.apps.get(key).resource
            root.putChild(key, self.apps.get(key).resource)

        # /
        root.putChild(
            '',
            wwwconfig.IndexResource(self.master,
                                    self.apps.get('base').static_dir))

        # /auth
        root.putChild('auth', auth.AuthRootResource(self.master))

        # /avatar
        root.putChild('avatar', avatar.AvatarResource(self.master))

        # /api
        root.putChild('api', rest.RestRootResource(self.master))

        # /ws
        root.putChild('ws', ws.WsResource(self.master))

        # /sse
        root.putChild('sse', sse.EventResource(self.master))

        self.root = root
        self.site = server.Site(root)

        # todo: need to store session infos in the db for multimaster
        # rough examination, it looks complicated, as all the session APIs are sync
        self.site.sessionFactory = server.Session

        # convert this to a tuple so it can't be appended anymore (in
        # case some dynamically created resources try to get reconfigs)
        self.reconfigurableResources = tuple(self.reconfigurableResources)
예제 #3
0
 def setUp(self):
     self.setUpAuthResource()
     self.rsrc = auth.AuthRootResource(self.master)
예제 #4
0
파일: service.py 프로젝트: dirkvdb/buildbot
    def setupSite(self, new_config):
        self.reconfigurableResources = []

        # we're going to need at least the base plugin (buildbot-www)
        if 'base' not in self.apps:
            raise RuntimeError("could not find buildbot-www; is it installed?")

        root = self.apps.get('base').resource
        for key, plugin in iteritems(new_config.www.get('plugins', {})):
            log.msg("initializing www plugin %r" % (key,))
            if key not in self.apps:
                raise RuntimeError(
                    "could not find plugin %s; is it installed?" % (key,))
            self.apps.get(key).setMaster(self.master)
            root.putChild(key, self.apps.get(key).resource)
        known_plugins = set(new_config.www.get('plugins', {})) | set(['base'])
        for plugin_name in set(self.apps.names) - known_plugins:
            log.msg("NOTE: www plugin %r is installed but not "
                    "configured" % (plugin_name,))

        # /
        root.putChild('', wwwconfig.IndexResource(
            self.master, self.apps.get('base').static_dir))

        # /auth
        root.putChild('auth', auth.AuthRootResource(self.master))

        # /avatar
        root.putChild('avatar', avatar.AvatarResource(self.master))

        # /api
        root.putChild('api', rest.RestRootResource(self.master))

        # /ws
        root.putChild('ws', ws.WsResource(self.master))

        # /sse
        root.putChild('sse', sse.EventResource(self.master))

        # /change_hook
        resource_obj = change_hook.ChangeHookResource(master=self.master)

        # FIXME: this does not work with reconfig
        change_hook_auth = new_config.www.get('change_hook_auth')
        if change_hook_auth is not None:
            resource_obj = self.setupProtectedResource(
                resource_obj, change_hook_auth)
        root.putChild("change_hook", resource_obj)

        self.root = root

        rotateLength = new_config.www.get(
            'logRotateLength') or self.master.log_rotation.rotateLength
        maxRotatedFiles = new_config.www.get(
            'maxRotatedFiles') or self.master.log_rotation.maxRotatedFiles

        class RotateLogSite(server.Site):

            """ A Site that logs to a separate file: http.log, and rotate its logs """

            def _openLogFile(self, path):
                try:
                    from twisted.python.logfile import LogFile
                    log.msg("Setting up http.log rotating %s files of %s bytes each" %
                            (maxRotatedFiles, rotateLength))
                    # not present in Twisted-2.5.0
                    if hasattr(LogFile, "fromFullPath"):
                        return LogFile.fromFullPath(path, rotateLength=rotateLength, maxRotatedFiles=maxRotatedFiles)
                    else:
                        log.msg(
                            "WebStatus: rotated http logs are not supported on this version of Twisted")
                except ImportError as e:
                    log.msg(
                        "WebStatus: Unable to set up rotating http.log: %s" % e)

                # if all else fails, just call the parent method
                return server.Site._openLogFile(self, path)

        httplog = None
        if new_config.www['logfileName']:
            httplog = os.path.abspath(
                os.path.join(self.master.basedir, new_config.www['logfileName']))
        self.site = RotateLogSite(root, logPath=httplog)

        self.site.sessionFactory = BuildbotSession

        # Make sure site.master is set. It is required for poller change_hook
        self.site.master = self.master
        # convert this to a tuple so it can't be appended anymore (in
        # case some dynamically created resources try to get reconfigs)
        self.reconfigurableResources = tuple(self.reconfigurableResources)
예제 #5
0
    def setupSite(self, new_config):
        self.reconfigurableResources = []
        root = self.apps.get('base').resource
        for key, plugin in new_config.www.get('plugins', {}).items():
            if key not in self.apps:
                raise RuntimeError(
                    "could not find plugin %s; is it installed?" % (key, ))
            print "putChild", key, self.apps.get(key).resource
            root.putChild(key, self.apps.get(key).resource)

        # /
        root.putChild(
            '',
            wwwconfig.IndexResource(self.master,
                                    self.apps.get('base').static_dir))

        # /auth
        root.putChild('auth', auth.AuthRootResource(self.master))

        # /avatar
        root.putChild('avatar', avatar.AvatarResource(self.master))

        # /api
        root.putChild('api', rest.RestRootResource(self.master))

        # /ws
        root.putChild('ws', ws.WsResource(self.master))

        # /sse
        root.putChild('sse', sse.EventResource(self.master))

        self.root = root

        def either(a, b):  # a if a else b for py2.4
            if a:
                return a
            else:
                return b

        rotateLength = either(new_config.www.get('logRotateLength'),
                              self.master.log_rotation.rotateLength)
        maxRotatedFiles = either(new_config.www.get('maxRotatedFiles'),
                                 self.master.log_rotation.maxRotatedFiles)

        class RotateLogSite(server.Site):
            """ A Site that logs to a separate file: http.log, and rotate its logs """
            def _openLogFile(self, path):
                try:
                    from twisted.python.logfile import LogFile
                    log.msg(
                        "Setting up http.log rotating %s files of %s bytes each"
                        % (maxRotatedFiles, rotateLength))
                    if hasattr(LogFile,
                               "fromFullPath"):  # not present in Twisted-2.5.0
                        return LogFile.fromFullPath(
                            path,
                            rotateLength=rotateLength,
                            maxRotatedFiles=maxRotatedFiles)
                    else:
                        log.msg(
                            "WebStatus: rotated http logs are not supported on this version of Twisted"
                        )
                except ImportError, e:
                    log.msg(
                        "WebStatus: Unable to set up rotating http.log: %s" %
                        e)

                # if all else fails, just call the parent method
                return server.Site._openLogFile(self, path)
예제 #6
0
 def setUp(self):
     self.setup_test_reactor()
     self.setUpAuthResource()
     self.rsrc = auth.AuthRootResource(self.master)
예제 #7
0
    def setupSite(self, new_config):
        self.reconfigurableResources = []

        # we're going to need at least the the base plugin (buildbot-www)
        if 'base' not in self.apps:
            raise RuntimeError("could not find buildbot-www; is it installed?")

        root = self.apps.get('base').resource
        for key, plugin in new_config.www.get('plugins', {}).items():
            log.msg("initializing www plugin %r" % (key, ))
            if key not in self.apps:
                raise RuntimeError(
                    "could not find plugin %s; is it installed?" % (key, ))
            self.apps.get(key).setMaster(self.master)
            root.putChild(key, self.apps.get(key).resource)
        known_plugins = set(new_config.www.get('plugins', {})) | set(['base'])
        for plugin_name in set(self.apps.names) - known_plugins:
            log.msg("NOTE: www plugin %r is installed but not "
                    "configured" % (plugin_name, ))

        # /
        root.putChild(
            '',
            wwwconfig.IndexResource(self.master,
                                    self.apps.get('base').static_dir))

        # /auth
        root.putChild('auth', auth.AuthRootResource(self.master))

        # /avatar
        root.putChild('avatar', avatar.AvatarResource(self.master))

        # /api
        root.putChild('api', rest.RestRootResource(self.master))

        # /ws
        root.putChild('ws', ws.WsResource(self.master))

        # /sse
        root.putChild('sse', sse.EventResource(self.master))

        # /change_hook
        resource_obj = change_hook.ChangeHookResource(master=self.master)

        # FIXME: this does not work with reconfig
        change_hook_auth = new_config.www.get('change_hook_auth')
        if change_hook_auth is not None:
            resource_obj = self.setupProtectedResource(resource_obj,
                                                       change_hook_auth)
        root.putChild("change_hook", resource_obj)

        self.root = root

        def either(a, b):  # a if a else b for py2.4
            if a:
                return a
            else:
                return b

        rotateLength = either(new_config.www.get('logRotateLength'),
                              self.master.log_rotation.rotateLength)
        maxRotatedFiles = either(new_config.www.get('maxRotatedFiles'),
                                 self.master.log_rotation.maxRotatedFiles)

        class RotateLogSite(server.Site):
            """ A Site that logs to a separate file: http.log, and rotate its logs """
            def _openLogFile(self, path):
                try:
                    from twisted.python.logfile import LogFile
                    log.msg(
                        "Setting up http.log rotating %s files of %s bytes each"
                        % (maxRotatedFiles, rotateLength))
                    if hasattr(LogFile,
                               "fromFullPath"):  # not present in Twisted-2.5.0
                        return LogFile.fromFullPath(
                            path,
                            rotateLength=rotateLength,
                            maxRotatedFiles=maxRotatedFiles)
                    else:
                        log.msg(
                            "WebStatus: rotated http logs are not supported on this version of Twisted"
                        )
                except ImportError, e:
                    log.msg(
                        "WebStatus: Unable to set up rotating http.log: %s" %
                        e)

                # if all else fails, just call the parent method
                return server.Site._openLogFile(self, path)
예제 #8
0
    def setupSite(self, new_config):
        self.reconfigurableResources = []

        # we're going to need at least the base plugin (buildbot-www)
        if 'base' not in self.apps:
            raise RuntimeError("could not find buildbot-www; is it installed?")

        root = self.apps.get('base').resource
        known_plugins = set(new_config.www.get('plugins', {})) | set(['base'])
        for key, plugin in list(iteritems(new_config.www.get('plugins', {}))):
            log.msg("initializing www plugin %r" % (key, ))
            if key not in self.apps:
                raise RuntimeError(
                    "could not find plugin %s; is it installed?" % (key, ))
            app = self.apps.get(key)
            app.setMaster(self.master)
            app.setConfiguration(plugin)
            root.putChild(unicode2bytes(key), app.resource)
            if not app.ui:
                del new_config.www['plugins'][key]
        for plugin_name in set(self.apps.names) - known_plugins:
            log.msg("NOTE: www plugin %r is installed but not "
                    "configured" % (plugin_name, ))

        # /
        root.putChild(
            b'',
            wwwconfig.IndexResource(self.master,
                                    self.apps.get('base').static_dir))

        # /auth
        root.putChild(b'auth', auth.AuthRootResource(self.master))

        # /avatar
        root.putChild(b'avatar', avatar.AvatarResource(self.master))

        # /api
        root.putChild(b'api', rest.RestRootResource(self.master))

        # /ws
        root.putChild(b'ws', ws.WsResource(self.master))

        # /sse
        root.putChild(b'sse', sse.EventResource(self.master))

        # /change_hook
        resource_obj = change_hook.ChangeHookResource(master=self.master)

        # FIXME: this does not work with reconfig
        change_hook_auth = new_config.www.get('change_hook_auth')
        if change_hook_auth is not None:
            resource_obj = self.setupProtectedResource(resource_obj,
                                                       change_hook_auth)
        root.putChild(b"change_hook", resource_obj)

        self.root = root

        rotateLength = new_config.www.get(
            'logRotateLength') or self.master.log_rotation.rotateLength
        maxRotatedFiles = new_config.www.get(
            'maxRotatedFiles') or self.master.log_rotation.maxRotatedFiles

        httplog = None
        if new_config.www['logfileName']:
            httplog = os.path.abspath(
                os.path.join(self.master.basedir,
                             new_config.www['logfileName']))
        self.site = BuildbotSite(root,
                                 logPath=httplog,
                                 rotateLength=rotateLength,
                                 maxRotatedFiles=maxRotatedFiles)

        self.site.sessionFactory = None

        # Make sure site.master is set. It is required for poller change_hook
        self.site.master = self.master
        # convert this to a tuple so it can't be appended anymore (in
        # case some dynamically created resources try to get reconfigs)
        self.reconfigurableResources = tuple(self.reconfigurableResources)