From 5c5d8ee3c1dbabbbd713964b3696cf4c6a8d630b Mon Sep 17 00:00:00 2001 From: Pierre Tardy Date: Fri, 5 Jan 2018 16:03:04 +0100 Subject: [PATCH] Fix api resource for python3 need to use bytes for managing endpoint paths Fixes #64 --- buildbot_travis/__init__.py | 2 +- buildbot_travis/api.py | 2 +- buildbot_travis/configurator.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/buildbot_travis/__init__.py b/buildbot_travis/__init__.py index d78c9c7..88b7fc8 100644 --- a/buildbot_travis/__init__.py +++ b/buildbot_travis/__init__.py @@ -23,7 +23,7 @@ # create the interface for the setuptools entry point ep = Application(__name__, "Buildbot travis custom ui") api = Api(ep) -ep.resource.putChild("api", api.app.resource()) +ep.resource.putChild(b"api", api.app.resource()) __all__ = ['TravisConfigurator', 'ep'] diff --git a/buildbot_travis/api.py b/buildbot_travis/api.py index 3c9e8ce..d4d1fd4 100644 --- a/buildbot_travis/api.py +++ b/buildbot_travis/api.py @@ -76,7 +76,7 @@ def saveCfg(self, cfg): @defer.inlineCallbacks def assertAllowed(self, request): try: - yield self.ep.master.www.assertUserAllowed(request, tuple(request.path.strip("/").split("/")), + yield self.ep.master.www.assertUserAllowed(request, tuple(request.path.strip(b"/").split(b"/")), request.method, {}) except Forbidden: request.setResponseCode(401) diff --git a/buildbot_travis/configurator.py b/buildbot_travis/configurator.py index 2c0f2d3..e83c3d4 100644 --- a/buildbot_travis/configurator.py +++ b/buildbot_travis/configurator.py @@ -35,7 +35,7 @@ def __init__(self, **kwargs): EndpointMatcherBase.__init__(self, **kwargs) def match(self, ep, action="get", options=None): - if "/".join(ep).startswith("buildbot_travis/api/config"): + if b"/".join(ep).startswith(b"buildbot_travis/api/config"): return defer.succeed(Match(self.master)) return defer.succeed(None)