From e60b252247247e812bc8b9ae5726150cbd96d923 Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Tue, 6 Sep 2016 21:32:16 -0400 Subject: [bug] allow webui to launch without bitmask_www package --- src/leap/bitmask/core/_web.py | 17 +++++++++++++++-- src/leap/bitmask/core/web/index.html | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src/leap') diff --git a/src/leap/bitmask/core/_web.py b/src/leap/bitmask/core/_web.py index 1a32fed..3f39e43 100644 --- a/src/leap/bitmask/core/_web.py +++ b/src/leap/bitmask/core/_web.py @@ -29,9 +29,17 @@ from twisted.application import service from twisted.web.resource import Resource from twisted.web.server import Site, NOT_DONE_YET from twisted.web.static import File +from twisted.python import log from leap.bitmask.core.dispatcher import CommandDispatcher +try: + import leap.bitmask_www + HAS_WEB_UI = True +except ImportError: + HAS_WEB_UI = False + + class HTTPDispatcherService(service.Service): @@ -45,8 +53,13 @@ class HTTPDispatcherService(service.Service): self.debug = debug def startService(self): - webdir = os.path.abspath( - pkg_resources.resource_filename('leap.bitmask_www', 'public')) + if HAS_WEB_UI: + webdir = os.path.abspath( + pkg_resources.resource_filename('leap.bitmask_www', 'public')) + else: + log.msg('leap.bitmask_www not found, serving bitmask.core web ui') + webdir = os.path.abspath( + pkg_resources.resource_filename('leap.bitmask.core', 'web')) root = File(webdir) api = Api(CommandDispatcher(self._core)) diff --git a/src/leap/bitmask/core/web/index.html b/src/leap/bitmask/core/web/index.html index 6ac9b29..7ffbb3f 100644 --- a/src/leap/bitmask/core/web/index.html +++ b/src/leap/bitmask/core/web/index.html @@ -1,7 +1,7 @@ - Bitmask WebSockets Endpoint + Bitmask.js example