Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9eacf3f79c | ||
|
|
83dd6ae836 | ||
|
|
20f8cdb00c | ||
|
|
26adada2db | ||
|
|
fa3bd1334a | ||
|
|
cd2b732b8f | ||
|
|
2fc54832f3 | ||
|
|
24780a9285 | ||
|
|
2e3b49f8b5 |
@@ -80,6 +80,6 @@ The TFW message format:
|
|||||||
|
|
||||||
Most of the components you need have docstrings included (hang on tight, this is work in progress) – refer to them for usage info.
|
Most of the components you need have docstrings included (hang on tight, this is work in progress) – refer to them for usage info.
|
||||||
|
|
||||||
In the `docs` folder you can find our Sphinx-based API documentation, which you can build using the included `Makefile` (you need to have Sphinx installed, please reach out to us if you have trouble building the docs).
|
In the `docs` folder you can find our Sphinx-based API documentation, which you can build using the `hack/tfw.sh` script in the [test-tutorial-framework](https://github.com/avatao-content/test-tutorial-framework) repository.
|
||||||
|
|
||||||
To get started you should take a look at the [test-tutorial-framework](https://github.com/avatao-content/test-tutorial-framework) repository, which serves as an example project as well.
|
To get started you should take a look at [test-tutorial-framework](https://github.com/avatao-content/test-tutorial-framework), which serves as an example project as well.
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class DirectoryMonitor(ObserverMixin):
|
class DirectoryMonitor(ObserverMixin):
|
||||||
def __init__(self, directories):
|
def __init__(self, ide_key, directories):
|
||||||
self.eventhandler = IdeReloadWatchdogEventHandler()
|
self.eventhandler = IdeReloadWatchdogEventHandler(ide_key)
|
||||||
for directory in directories:
|
for directory in directories:
|
||||||
self.observer.schedule(self.eventhandler, directory, recursive=True)
|
self.observer.schedule(self.eventhandler, directory, recursive=True)
|
||||||
|
|
||||||
@@ -44,8 +44,9 @@ class DirectoryMonitor(ObserverMixin):
|
|||||||
|
|
||||||
|
|
||||||
class IdeReloadWatchdogEventHandler(FileSystemWatchdogEventHandler):
|
class IdeReloadWatchdogEventHandler(FileSystemWatchdogEventHandler):
|
||||||
def __init__(self):
|
def __init__(self, ide_key):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.ide_key = ide_key
|
||||||
self.uplink = ServerUplinkConnector()
|
self.uplink = ServerUplinkConnector()
|
||||||
self._paused = False
|
self._paused = False
|
||||||
self.ignore = 0
|
self.ignore = 0
|
||||||
@@ -65,7 +66,7 @@ class IdeReloadWatchdogEventHandler(FileSystemWatchdogEventHandler):
|
|||||||
return
|
return
|
||||||
LOG.debug(event)
|
LOG.debug(event)
|
||||||
self.uplink.send({
|
self.uplink.send({
|
||||||
'key': 'ide',
|
'key': self.ide_key,
|
||||||
'data': {'command': 'reload'}
|
'data': {'command': 'reload'}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,12 @@ class DirectoryMonitoringEventHandler(EventHandlerBase, MonitorManagerMixin):
|
|||||||
def __init__(self, key, directory):
|
def __init__(self, key, directory):
|
||||||
super().__init__(key)
|
super().__init__(key)
|
||||||
self._directory = directory
|
self._directory = directory
|
||||||
MonitorManagerMixin.__init__(self, DirectoryMonitor, self._directory)
|
MonitorManagerMixin.__init__(
|
||||||
|
self,
|
||||||
|
DirectoryMonitor,
|
||||||
|
key,
|
||||||
|
self._directory
|
||||||
|
)
|
||||||
|
|
||||||
self.commands = {
|
self.commands = {
|
||||||
'pause': self.pause,
|
'pause': self.pause,
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ class IdeEventHandler(EventHandlerBase, MonitorManagerMixin):
|
|||||||
MonitorManagerMixin.__init__(
|
MonitorManagerMixin.__init__(
|
||||||
self,
|
self,
|
||||||
DirectoryMonitor,
|
DirectoryMonitor,
|
||||||
|
self.key,
|
||||||
self.filemanager.allowed_directories
|
self.filemanager.allowed_directories
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
||||||
# All Rights Reserved. See LICENSE file for details.
|
# All Rights Reserved. See LICENSE file for details.
|
||||||
|
|
||||||
|
from functools import update_wrapper
|
||||||
|
|
||||||
|
|
||||||
class lazy_property:
|
class lazy_property:
|
||||||
"""
|
"""
|
||||||
@@ -9,7 +11,7 @@ class lazy_property:
|
|||||||
"""
|
"""
|
||||||
def __init__(self, func):
|
def __init__(self, func):
|
||||||
self.func = func
|
self.func = func
|
||||||
self.__doc__ = func.__doc__
|
update_wrapper(self, func)
|
||||||
|
|
||||||
def __get__(self, instance, owner):
|
def __get__(self, instance, owner):
|
||||||
if instance is None:
|
if instance is None:
|
||||||
|
|||||||
@@ -1,32 +1,46 @@
|
|||||||
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
||||||
# All Rights Reserved. See LICENSE file for details.
|
# All Rights Reserved. See LICENSE file for details.
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from tfw.networking.event_handlers import ServerUplinkConnector
|
from tfw.networking.event_handlers import ServerUplinkConnector
|
||||||
|
|
||||||
|
|
||||||
class MessageSender:
|
class MessageSender:
|
||||||
"""
|
"""
|
||||||
Provides a mechanism to send messages to our frontend messaging component which
|
Provides mechanisms to send messages to our frontend messaging component.
|
||||||
displays messages with the key "message".
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, custom_key: str = None):
|
def __init__(self):
|
||||||
self.server_connector = ServerUplinkConnector()
|
self.server_connector = ServerUplinkConnector()
|
||||||
self.key = custom_key or 'message'
|
self.key = 'message'
|
||||||
|
self.queue_key = 'queueMessages'
|
||||||
|
|
||||||
def send(self, originator, message):
|
def send(self, originator, message):
|
||||||
"""
|
"""
|
||||||
Sends a message to the key specified in __init__.
|
Sends a message.
|
||||||
:param originator: name of sender to be displayed on the frontend
|
:param originator: name of sender to be displayed on the frontend
|
||||||
:param message: message to send
|
:param message: message to send
|
||||||
"""
|
"""
|
||||||
data = {
|
data = {
|
||||||
'originator': originator,
|
'originator': originator,
|
||||||
'timestamp': datetime.now().isoformat(),
|
|
||||||
'message': message
|
'message': message
|
||||||
}
|
}
|
||||||
self.server_connector.send({
|
self.server_connector.send({
|
||||||
'key': self.key,
|
'key': self.key,
|
||||||
'data': data
|
'data': data
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def queue_messages(self, originator, messages):
|
||||||
|
"""
|
||||||
|
Queues a list of messages to be displayed in a chatbot-like manner.
|
||||||
|
:param originator: name of sender to be displayed on the frontend
|
||||||
|
:param messages: list of messages to queue
|
||||||
|
"""
|
||||||
|
data = {
|
||||||
|
'messages': [
|
||||||
|
{'message': message, 'originator': originator}
|
||||||
|
for message in messages
|
||||||
|
]
|
||||||
|
}
|
||||||
|
self.server_connector.send({
|
||||||
|
'key': self.queue_key,
|
||||||
|
'data': data
|
||||||
|
})
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ from os.path import dirname, realpath, join
|
|||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
|
||||||
here = dirname(realpath(__file__))
|
here = dirname(realpath(__file__))
|
||||||
|
|
||||||
with open(join(here, 'VERSION'), 'r') as ifile:
|
with open(join(here, 'VERSION'), 'r') as ifile:
|
||||||
@@ -10,7 +9,8 @@ with open(join(here, 'VERSION'), 'r') as ifile:
|
|||||||
with open(join(here, 'requirements.txt'), 'r') as ifile:
|
with open(join(here, 'requirements.txt'), 'r') as ifile:
|
||||||
requirements = ifile.read().splitlines()
|
requirements = ifile.read().splitlines()
|
||||||
|
|
||||||
setup(name='tfw',
|
setup(
|
||||||
|
name = 'tfw',
|
||||||
version = version,
|
version = version,
|
||||||
description = 'Avatao tutorial-framework',
|
description = 'Avatao tutorial-framework',
|
||||||
url = 'https://github.com/avatao-content/baseimage-tutorial-framework',
|
url = 'https://github.com/avatao-content/baseimage-tutorial-framework',
|
||||||
@@ -20,4 +20,10 @@ setup(name='tfw',
|
|||||||
packages = find_packages('lib'),
|
packages = find_packages('lib'),
|
||||||
package_dir = {'': 'lib'},
|
package_dir = {'': 'lib'},
|
||||||
install_requires = requirements,
|
install_requires = requirements,
|
||||||
zip_safe=False)
|
extras_require = {
|
||||||
|
'docs': [
|
||||||
|
'sphinx >= 1.7.0',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
zip_safe = False,
|
||||||
|
)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ logfile=/dev/null
|
|||||||
logfile_maxbytes=0
|
logfile_maxbytes=0
|
||||||
loglevel = debug
|
loglevel = debug
|
||||||
pidfile = /tmp/supervisord.pid
|
pidfile = /tmp/supervisord.pid
|
||||||
|
strip_ansi=true
|
||||||
|
|
||||||
[inet_http_server]
|
[inet_http_server]
|
||||||
port = 127.0.0.1:%(ENV_TFW_SUPERVISOR_HTTP_PORT)s
|
port = 127.0.0.1:%(ENV_TFW_SUPERVISOR_HTTP_PORT)s
|
||||||
|
|||||||
Reference in New Issue
Block a user