Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/nutrinoweb/activity.py
diff options
context:
space:
mode:
Diffstat (limited to 'nutrinoweb/activity.py')
-rw-r--r--nutrinoweb/activity.py48
1 files changed, 39 insertions, 9 deletions
diff --git a/nutrinoweb/activity.py b/nutrinoweb/activity.py
index 0ece4a7..f02b619 100644
--- a/nutrinoweb/activity.py
+++ b/nutrinoweb/activity.py
@@ -1,5 +1,5 @@
# python import
-import logging
+import os, sys, threading, time
# gettext import
from gettext import gettext as _
@@ -8,12 +8,15 @@ from sugar.activity import activity
# hulahop import
from hulahop.webview import WebView
-# atoideweb import - first to update lib path
-import run
+# add lib path to current python path
+sys.path.append(os.path.join(activity.get_bundle_path(), 'lib'))
# server import
from server import config
-from server.flask import logger
+from server.flask import app, run_app as __run, logger
+
+# nutriweb import
+from nutrinoweb.controllers import app
# get port from config
@@ -23,28 +26,53 @@ _port = '5000' if _port is None or _port == '' else _port
URL_BASE = 'http://localhost:%s' % _port
+class ThreadServer(threading.Thread):
+
+ def __init__(self, activity_):
+ # init parent
+ threading.Thread.__init__(self)
+ # main flag
+ self._die = False
+ # start right now
+ self.start()
+
+ def kill(self):
+ self._die = True
+
+ def run(self):
+ # do run
+ __run()
+ # ...
+ while self._die is False:
+ continue
+ # ..
+ del app
+
+
def _toolbar_changed(toolbox, page, activity_):
"""Catch toolbox activity tab focus to display settings screen.
"""
# is the activity tab?
if page == 0:
# show the activity screen
- activity_.change_screen('activity')
+ activity_.change_screen('main')
else:
pass
# propagate it
return True
-class NutrinoWebActivity(run.Server, activity.Activity):
+class NutrinoWebActivity(activity.Activity):
def __init__(self, handle):
+ # init thread server
+ self._thread = ThreadServer(self)
+ # ..
+ time.sleep(5)
# init parents
activity.Activity.__init__(self, handle)
self.max_participants = 1
# ..
- run.Server.__init__(self)
- # ..
if config.Config().get('activity>use-toolbar', type_=bool):
self.__init_toolbar()
else:
@@ -97,5 +125,7 @@ class NutrinoWebActivity(run.Server, activity.Activity):
pass
def close(self, skip_save=False):
- run.Server.close(self)
+ # stop the thread
+ self._thread.kill()
+ # ..
activity.Activity.close(self, skip_save=True)