mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 19:21: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__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
BUILD_ARTIFACTS = [
|
BUILD_ARTIFACTS = (
|
||||||
"*.a",
|
"*.a",
|
||||||
"*.class",
|
"*.class",
|
||||||
"*.dll",
|
"*.dll",
|
||||||
@ -31,7 +31,7 @@ BUILD_ARTIFACTS = [
|
|||||||
"*.tar.gz",
|
"*.tar.gz",
|
||||||
"*.zip",
|
"*.zip",
|
||||||
"*__pycache__*"
|
"*__pycache__*"
|
||||||
]
|
)
|
||||||
|
|
||||||
|
|
||||||
class IdeEventHandler(FrontendEventHandlerBase):
|
class IdeEventHandler(FrontendEventHandlerBase):
|
||||||
@ -71,13 +71,7 @@ class IdeEventHandler(FrontendEventHandlerBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.monitor = InotifyObserver(self.filemanager.allowed_directories, exclude=BUILD_ARTIFACTS)
|
self.monitor = InotifyObserver(self.filemanager.allowed_directories, exclude=BUILD_ARTIFACTS)
|
||||||
def on_modified(event):
|
self.monitor.on_modified = self._reload_frontend
|
||||||
LOG.debug(event)
|
|
||||||
self.server_connector.send_message({
|
|
||||||
'key': 'ide',
|
|
||||||
'data': {'command': 'reload'}
|
|
||||||
}, Scope.WEBSOCKET)
|
|
||||||
self.monitor.on_modified = on_modified
|
|
||||||
self.monitor.start()
|
self.monitor.start()
|
||||||
|
|
||||||
self.commands = {
|
self.commands = {
|
||||||
@ -88,6 +82,12 @@ class IdeEventHandler(FrontendEventHandlerBase):
|
|||||||
'exclude': self.exclude
|
'exclude': self.exclude
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _reload_frontend(self, event):
|
||||||
|
self.server_connector.send_message({
|
||||||
|
'key': 'ide',
|
||||||
|
'data': {'command': 'reload'}
|
||||||
|
}, Scope.WEBSOCKET)
|
||||||
|
|
||||||
def read(self, data):
|
def read(self, data):
|
||||||
"""
|
"""
|
||||||
Read the currently selected file.
|
Read the currently selected file.
|
||||||
|
Loading…
Reference in New Issue
Block a user