mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 14:11:31 +00:00
Refactor IdeEventHandler
This commit is contained in:
parent
28f09086a2
commit
5f5fc1a8c9
@ -10,7 +10,7 @@ from tfw.components.inotify import InotifyObserver
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
BUILD_ARTIFACTS = [
|
||||
BUILD_ARTIFACTS = (
|
||||
"*.a",
|
||||
"*.class",
|
||||
"*.dll",
|
||||
@ -31,7 +31,7 @@ BUILD_ARTIFACTS = [
|
||||
"*.tar.gz",
|
||||
"*.zip",
|
||||
"*__pycache__*"
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class IdeEventHandler(FrontendEventHandlerBase):
|
||||
@ -71,13 +71,7 @@ class IdeEventHandler(FrontendEventHandlerBase):
|
||||
)
|
||||
|
||||
self.monitor = InotifyObserver(self.filemanager.allowed_directories, exclude=BUILD_ARTIFACTS)
|
||||
def on_modified(event):
|
||||
LOG.debug(event)
|
||||
self.server_connector.send_message({
|
||||
'key': 'ide',
|
||||
'data': {'command': 'reload'}
|
||||
}, Scope.WEBSOCKET)
|
||||
self.monitor.on_modified = on_modified
|
||||
self.monitor.on_modified = self._reload_frontend
|
||||
self.monitor.start()
|
||||
|
||||
self.commands = {
|
||||
@ -88,6 +82,12 @@ class IdeEventHandler(FrontendEventHandlerBase):
|
||||
'exclude': self.exclude
|
||||
}
|
||||
|
||||
def _reload_frontend(self, event):
|
||||
self.server_connector.send_message({
|
||||
'key': 'ide',
|
||||
'data': {'command': 'reload'}
|
||||
}, Scope.WEBSOCKET)
|
||||
|
||||
def read(self, data):
|
||||
"""
|
||||
Read the currently selected file.
|
||||
|
Loading…
Reference in New Issue
Block a user