コード例 #1
0
 def getChild(self, path, request):
     if not request.prepath:
         return None
     cookie = request.getCookie(self.cookieKey)
     setupURL = urlToChild(request, INIT_SESSION, *([path] + request.postpath))
     request.setupSessionURL = setupURL
     request.setupSession = lambda: Redirect(setupURL)
     if path.startswith(SESSION_KEY):
         key = path[len(SESSION_KEY) :]
         if key not in self.sessions:
             return redirectToSession(request, "__start_session__")
         self.sessions[key].setLifetime(self.sessionLifetime)
         if cookie == key:
             return redirectToSession(request, "__session_just_started__")
         else:
             _setSession(self, request, key)
             return self.resource
     elif cookie in self.sessions:
         _setSession(self, request, cookie)
         return getResource(self.resource, path, request)
     elif path == INIT_SESSION:
         newCookie = _sessionCookie()
         request.addCookie(self.cookieKey, newCookie, path="/")
         self.sessions[newCookie] = GuardSession(self, newCookie)
         sz = self.sessions[newCookie]
         sz.checkExpired()
         rd = Redirect(urlToChild(request, SESSION_KEY + newCookie, *request.postpath))
         rd.isLeaf = 1
         return rd
     else:
         request.getSession = lambda interface=None: None
         return getResource(self.resource, path, request)
コード例 #2
0
ファイル: guard.py プロジェクト: KatiaBorges/exeLearning
 def getChild(self, path, request):
     if not request.prepath:
         return None
     cookie = request.getCookie(self.cookieKey)
     setupURL = urlToChild(request, INIT_SESSION, *([path]+request.postpath))
     request.setupSessionURL = setupURL
     request.setupSession = lambda: Redirect(setupURL)
     if path.startswith(SESSION_KEY):
         key = path[len(SESSION_KEY):]
         if key not in self.sessions:
             return redirectToSession(request, '__start_session__')
         self.sessions[key].setLifetime(self.sessionLifetime)
         if cookie == key:
             # /sessionized-url/${SESSION_KEY}aef9c34aecc3d9148/foo
             #                  ^
             #                  we are this getChild
             # with a matching cookie
             return redirectToSession(request, '__session_just_started__')
         else:
             # We attempted to negotiate the session but failed (the user
             # probably has cookies disabled): now we're going to return the
             # resource we contain.  In general the getChild shouldn't stop
             # there.
             # /sessionized-url/${SESSION_KEY}aef9c34aecc3d9148/foo
             #                  ^ we are this getChild
             # without a cookie (or with a mismatched cookie)
             _setSession(self, request, key)
             return self.resource
     elif cookie in self.sessions:
         # /sessionized-url/foo
         #                 ^ we are this getChild
         # with a session
         _setSession(self, request, cookie)
         return getResource(self.resource, path, request)
     elif path == INIT_SESSION:
         # initialize the session
         # /sessionized-url/session-init
         #                  ^ this getChild
         # without a session
         newCookie = _sessionCookie()
         request.addCookie(self.cookieKey, newCookie, path="/")
         sz = self.sessions[newCookie] = GuardSession(self, newCookie)
         sz.checkExpired()
         rd = Redirect(urlToChild(request, SESSION_KEY+newCookie,
                                           *request.postpath))
         rd.isLeaf = 1
         return rd
     else:
         # /sessionized-url/foo
         #                 ^ we are this getChild
         # without a session
         request.getSession = lambda interface=None: None
         return getResource(self.resource, path, request)
コード例 #3
0
ファイル: multipkg.py プロジェクト: toofishes/multipkg
 def deferred_search(self, request):
     pkgname = request.prepath[-1]
     qi = self.queue.new(pkgname)
     self.finder.search(pkgname)
     address = qi.wait()
     if address != None:
         print("found: %s %s" % (address, pkgname))
         resource = Redirect("http://%s:%s/cache/%s" % (address, str(DEF_PORT), pkgname))
         resource.render(request)
     else:
         print("not found: %s" % pkgname)
         resource = NoResource()
         resource.render(request)
     request.finish()
     return request
コード例 #4
0
ファイル: utils.py プロジェクト: ddormer/Querryl
 def __init__(self, port):
     self.port = port
     Redirect.__init__(self, None)
コード例 #5
0
ファイル: test_webclient.py プロジェクト: hu19891110/twisted
 def __init__(self, *a, **kw):
     Redirect.__init__(self, *a, **kw)
     self.count = 0
コード例 #6
0
ファイル: builder.py プロジェクト: kusoof/wprof
    def force(self, req):
        """

        Custom properties can be passed from the web form.  To do
        this, subclass this class, overriding the force() method.  You
        can then determine the properties (usually from form values,
        by inspecting req.args), then pass them to this superclass
        force method.
        
        """
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]

        r = "The web-page 'force build' button was pressed by '%s': %s\n" \
            % (html.escape(name), html.escape(reason))
        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s'"
                " by user '%s'" %
                (self.builder_status.getName(), branch, revision, name))

        if not self.builder_control:
            # TODO: tell the web user that their request was denied
            log.msg("but builder control is disabled")
            return Redirect("..")

        if self.isUsingUserPasswd(req):
            if not self.authUser(req):
                return Redirect("../../authfail")

        # keep weird stuff out of the branch revision, and property strings.
        # TODO: centralize this somewhere.
        if not re.match(r'^[\w\.\-\/]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect("..")
        if not re.match(r'^[\w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect("..")
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect("..")
        if not branch:
            branch = None
        if not revision:
            revision = None

        # TODO: if we can authenticate that a particular User pushed the
        # button, use their name instead of None, so they'll be informed of
        # the results.
        # TODO2: we can authenticate that a particular User pushed the button
        # now, so someone can write this support. but it requires a
        # buildbot.changes.changes.Change instance which is tedious at this
        # stage to compute
        s = SourceStamp(branch=branch, revision=revision)
        req = BuildRequest(r,
                           s,
                           builderName=self.builder_status.getName(),
                           properties=properties)
        try:
            self.builder_control.requestBuildSoon(req)
        except interfaces.NoSlaveError:
            # TODO: tell the web user that their request could not be
            # honored
            pass
        # send the user back to the builder page
        return Redirect(".")
コード例 #7
0
 def render(self, request):
     self.count += 1
     return Redirect.render(self, request)
コード例 #8
0
ファイル: http.py プロジェクト: 4sp1r3/opencanary
 def render(self, request):
     request.setHeader('Server', self.factory.banner)
     return Redirect.render(self, request)
コード例 #9
0
# Twisted redirect subdirectory to another domain
from twisted.web.util import Redirect
fooDotComResource.putChild("bar", Redirect("http://foobar.com/bar"))
コード例 #10
0
 def getChild(self, path, req):
     s = self.getStatus(req)
     slave = s.getSlave(self.slavename)
     if path == "shutdown":
         return ShutdownActionResource(slave)
     return Redirect(path_to_slave(req, slave))
コード例 #11
0
 def ping(self, req):
     log.msg("web ping of builder '%s'" % self.builder_status.getName())
     self.builder_control.ping()  # TODO: there ought to be an ISlaveControl
     return Redirect("../../waterfall")
コード例 #12
0
 def render(self, request):
     request.setHeader('Server', self.factory.banner)
     return Redirect.render(self, request)
コード例 #13
0
 def __init__(self, request, factory):
     Redirect.__init__(self, request)
     self.factory = factory
コード例 #14
0
def make_redirect(parent, name, location_relative_ref):
    redirect = Redirect(location_relative_ref)
    parent.putChild(name, redirect)
    return redirect
コード例 #15
0
ファイル: builder.py プロジェクト: kusoof/wprof
 def ping(self, req):
     log.msg("web ping of builder '%s'" % self.builder_status.getName())
     self.builder_control.ping()  # TODO: there ought to be an ISlaveControl
     # send the user back to the builder page
     return Redirect(".")
コード例 #16
0
ファイル: utils.py プロジェクト: ddormer/Querryl
 def render(self, request):
     self.url = 'https://%s:%s' % (
         request.getRequestHostname(),
         self.port)
     return Redirect.render(self, request)
コード例 #17
0
 def render(self, request):
     self.count += 1
     return Redirect.render(self, request)
コード例 #18
0
ファイル: web.py プロジェクト: dekpient/UpStage
def dumbRedirect(x):
    """Redirect to the current directory"""
    return Redirect(".")
コード例 #19
0
ファイル: guard.py プロジェクト: KatiaBorges/exeLearning
def redirectToSession(request, garbage):
    rd = Redirect(urlToChild(request, *request.postpath, **{garbage:1}))
    rd.isLeaf = 1
    return rd
コード例 #20
0
ファイル: monitor.py プロジェクト: dl1bz/hbmonitor3-mod
    # Start update loop
    update_stats = task.LoopingCall(build_stats)
    update_stats.start(FREQUENCY)

    # Start a timout loop
    if CLIENT_TIMEOUT > 0:
        timeout = task.LoopingCall(timeout_clients)
        timeout.start(10)

    # Connect to HBlink
    reactor.connectTCP(HBLINK_IP, HBLINK_PORT, reportClientFactory())

    # Create websocket server to push content to clients
    dashboard_server = dashboardFactory('wss://*:9488')
    dashboard_server.protocol = dashboard
    sslContext = ssl.DefaultOpenSSLContextFactory('/etc/letsencrypt/live/dmr02.bzsax.de/privkey.pem','/etc/letsencrypt/live/dmr02.bzsax.de/fullchain.pem')
    reactor.listenSSL(9488, dashboard_server, sslContext)

    # Create static web server to push initial index.html
    website = Site(web_server())
    reactor.listenSSL(WEB_SERVER_PORT, website, sslContext)

    # Redirect with twisted to SSL port
    HTTPnoSSL = Resource()
    no_SSL_URL = "https://dmr02.bzsax.de:8488"
    HTTPnoSSL.putChild(b'', Redirect(bytes(no_SSL_URL, 'utf-8')))
    reactor.listenTCP(8088, Site(HTTPnoSSL))

    reactor.run()
コード例 #21
0
ファイル: http.py プロジェクト: 4sp1r3/opencanary
 def __init__(self, request, factory):
     Redirect.__init__(self, request)
     self.factory = factory
コード例 #22
0
ファイル: chromium_status_bb7.py プロジェクト: kusoof/wprof
    def force(self, req):
        """ Overriden method from builders.StatusResourceBuilder. The only
    change to original behavior is that it sets 'clobber' value on the
    BuildRequest.properties."""

        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        clobber = req.args.get("clobber", [False])[0]
        slavename = req.args.get("slavename", [False])[0]

        if clobber:
            clobber_str = ' (clobbered)'
        else:
            clobber_str = ''
        r = ("The web-page 'force build' button%s was pressed by %s: %s" %
             (clobber_str, name, reason))

        message = ("web forcebuild of builder '%s', branch='%s', revision='%s'"
                   ", clobber='%s'")
        log.msg(
            message %
            (self.builder_status.getName(), branch, revision, str(clobber)))

        if not self.builder_control:
            # TODO: tell the web user that their request was denied
            log.msg("but builder control is disabled")
            return Redirect("..")

        # keep weird stuff out of the branch and revision strings. TODO:
        # centralize this somewhere.
        if not re.match(r'^[\w\.\-\/]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect("..")
        if not re.match(r'^[\w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect("..")
        if branch == "":
            branch = None
        if revision == "":
            revision = None

        # TODO: if we can authenticate that a particular User pushed the
        # button, use their name instead of None, so they'll be informed of
        # the results.
        s = sourcestamp.SourceStamp(branch=branch, revision=revision)
        props = process.properties.Properties()
        if clobber:
            props.setProperty("clobber", True, "Scheduler")
        if slavename:
            props.setProperty("slavename", slavename, "Scheduler")
        req = process.base.BuildRequest(
            r, s, builderName=self.builder_status.getName(), properties=props)
        try:
            self.builder_control.requestBuildSoon(req)
        except interfaces.NoSlaveError:
            # TODO: tell the web user that their request could not be
            # honored
            pass
        # Sends the user back to the waterfall page.
        return Redirect("../..")
コード例 #23
0
 def __init__(self, *a, **kw):
     Redirect.__init__(self, *a, **kw)
     self.count = 0
コード例 #24
0
    def __init__(self, providers):
        resource.Resource.__init__(self)

        self.putChild('', Redirect('/gui'))
        self.putChild(b'api', APIEndpoint(providers))
        self.putChild(b'gui', File(os.path.join(BASE_DIR, 'webapp', 'dist')))
コード例 #25
0
ファイル: guard.py プロジェクト: fxia22/ASM_xf
 def getChild(self, path, request):
     # XXX refactor with PerspectiveWrapper
     if not request.prepath:
         return None
     pp = request.prepath.pop()
     _urlToMe = request.prePathURL()
     request.prepath.append(pp)
     def urlToChild(*ar):
         c = '/'.join(ar)
         if _urlToMe[-1] == '/':
             # this SHOULD only happen in the case where the URL is just the hostname
             return _urlToMe + c
         else:
             return _urlToMe + '/' + c
     # XXX
     # print "I think I'm at:", _urlToMe
     cookie = request.getCookie(self.cookieKey)
     setupURL = request.setupSessionURL = urlToChild(INIT_SESSION, *([path]+request.postpath))
     request.setupSession = lambda: Redirect(setupURL)
     if self.sessions.has_key(path):
         self.sessions[path].setLifetime(1800)
         if cookie == path:
             # /sessionized-url/aef9c34aecc3d9148/foo
             #                  ^
             #                  we are this getChild
             # with a matching cookie
             rd = Redirect(urlToChild(*request.postpath) +
                           # this next bit prevents 'redirect cycles' in
                           # wget (and possibly other browsers)
                           "?__session_just_started__=1")
             rd.isLeaf = 1
             return rd
         else:
             # We attempted to negotiate the session but failed (the user
             # probably has cookies disabled): now we're going to return the
             # resource we contain.  In general the getChild shouldn't stop
             # there.
             # /sessionized-url/aef9c34aecc3d9148/foo
             #                 ^ we are this getChild
             # without a cookie (or with a mismatched cookie)
             _setSession(self, request, path)
             return self.resource
     elif self.sessions.has_key(cookie):
         # /sessionized-url/foo
         #                 ^ we are this getChild
         # with a session
         _setSession(self, request, cookie)
         return self.resource.getChildWithDefault(path, request)
     elif path == INIT_SESSION:
         # initialize the session
         # /sessionized-url/session-init
         #                  ^ this getChild
         # without a session
         newCookie = _sessionCookie()
         request.addCookie(self.cookieKey, newCookie, path="/")
         rd = Redirect(urlToChild(newCookie,*request.postpath))
         rd.isLeaf = 1
         sz = self.sessions[newCookie] = GuardSession(self, newCookie)
         sz.checkExpired()
         return rd
     else:
         # /sessionized-url/foo
         #                 ^ we are this getChild
         # without a session
         request.getSession = lambda interface=None: None
         return self.resource.getChildWithDefault(path, request)
コード例 #26
0
ファイル: slaves.py プロジェクト: kusoof/wprof
 def getChild(self, path, req):
     s = self.getStatus(req)
     slave = s.getSlave(self.slavename)
     if path == "shutdown" and self.getControl(req):
         slave.setGraceful(True)
     return Redirect(path_to_slave(req, slave))