summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2016-09-06 21:32:16 -0400
committerKali Kaneko (leap communications) <kali@leap.se>2016-09-06 21:32:16 -0400
commite60b252247247e812bc8b9ae5726150cbd96d923 (patch)
tree4721d213893d144a0198a62e3195c8e154c7d316
parent728ffae25134b6d68be7567803ed8310a18a86a6 (diff)
[bug] allow webui to launch without bitmask_www package
-rw-r--r--src/leap/bitmask/core/_web.py17
-rw-r--r--src/leap/bitmask/core/web/index.html2
2 files changed, 16 insertions, 3 deletions
diff --git a/src/leap/bitmask/core/_web.py b/src/leap/bitmask/core/_web.py
index 1a32fed7..3f39e435 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 6ac9b29e..7ffbb3f1 100644
--- a/src/leap/bitmask/core/web/index.html
+++ b/src/leap/bitmask/core/web/index.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Bitmask WebSockets Endpoint</title>
+ <title>Bitmask.js example</title>
<script src="bitmask.js"></script>
<script type="text/javascript">
var ellog = null;