Renamed wait plugin to sleep
This commit is contained in:
parent
7d30328e21
commit
203b513c9e
@ -2,7 +2,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from config import Config
|
from config import Config
|
||||||
from plugins import WaitPlugin, SyncPlugin
|
from plugins import SleepPlugin, SyncPlugin
|
||||||
from plugin_repository import PluginRepository
|
from plugin_repository import PluginRepository
|
||||||
from program_executor import ProgramExecutor
|
from program_executor import ProgramExecutor
|
||||||
from http_server import ControllerHTTPServer
|
from http_server import ControllerHTTPServer
|
||||||
@ -33,18 +33,18 @@ def main():
|
|||||||
http_server.start()
|
http_server.start()
|
||||||
|
|
||||||
compiler_repo = PluginRepository()
|
compiler_repo = PluginRepository()
|
||||||
compiler_repo.register_plugin(WaitPlugin)
|
compiler_repo.register_plugin(SleepPlugin)
|
||||||
compiler_repo.register_plugin(SyncPlugin)
|
compiler_repo.register_plugin(SyncPlugin)
|
||||||
|
|
||||||
# Example code:
|
# Example code:
|
||||||
compiler_repo.load_plugin("wait")
|
compiler_repo.load_plugin("sleep")
|
||||||
compiler_repo.load_plugin("sync")
|
compiler_repo.load_plugin("sync")
|
||||||
program = []
|
program = []
|
||||||
program.append(compiler_repo.get_compiler("wait").compile(secs=2))
|
program.append(compiler_repo.get_compiler("sleep").compile(secs=2))
|
||||||
program.append(compiler_repo.get_compiler("wait").compile(secs=3))
|
program.append(compiler_repo.get_compiler("sleep").compile(secs=3))
|
||||||
program.append(compiler_repo.get_compiler("sync").compile(nodes=2, name="test"))
|
program.append(compiler_repo.get_compiler("sync").compile(nodes=2, name="test"))
|
||||||
program.append(compiler_repo.get_compiler("wait").compile(secs=10))
|
program.append(compiler_repo.get_compiler("sleep").compile(secs=10))
|
||||||
program.append(compiler_repo.get_compiler("wait").compile(secs=10))
|
program.append(compiler_repo.get_compiler("sleep").compile(secs=10))
|
||||||
|
|
||||||
# prepare execution
|
# prepare execution
|
||||||
executor = ProgramExecutor(program, loop=True)
|
executor = ProgramExecutor(program, loop=True)
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
from .abstract_plugin import AbstractCommand, AbstractCommandCompiler, AbstractPlugin
|
from .abstract_plugin import AbstractCommand, AbstractCommandCompiler, AbstractPlugin
|
||||||
from .wait_plugin import WaitPlugin
|
from .sleep_plugin import SleepPlugin
|
||||||
from .sync_plugin import SyncPlugin
|
from .sync_plugin import SyncPlugin
|
@ -5,7 +5,7 @@ import logging
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
class WaitCommand(AbstractCommand):
|
class SleepCommand(AbstractCommand):
|
||||||
|
|
||||||
def __init__(self, logger: logging.Logger, secs: float):
|
def __init__(self, logger: logging.Logger, secs: float):
|
||||||
|
|
||||||
@ -25,31 +25,31 @@ class WaitCommand(AbstractCommand):
|
|||||||
|
|
||||||
def describe(self) -> dict:
|
def describe(self) -> dict:
|
||||||
return {
|
return {
|
||||||
"command": "wait",
|
"command": "sleep",
|
||||||
"params": {
|
"params": {
|
||||||
"secs": self._secs
|
"secs": self._secs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class WaitCompiler(AbstractCommandCompiler):
|
class SleepCompiler(AbstractCommandCompiler):
|
||||||
|
|
||||||
def __init__(self, logger: logging.Logger):
|
def __init__(self, logger: logging.Logger):
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
|
|
||||||
def compile(self, secs: float) -> AbstractCommand:
|
def compile(self, secs: float) -> AbstractCommand:
|
||||||
return WaitCommand(self._logger, secs)
|
return SleepCommand(self._logger, secs)
|
||||||
|
|
||||||
|
|
||||||
class WaitPlugin(AbstractPlugin):
|
class SleepPlugin(AbstractPlugin):
|
||||||
plugin_name = "wait"
|
plugin_name = "sleep"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._logger = logging.getLogger("plugin").getChild("wait")
|
self._logger = logging.getLogger("plugin").getChild("sleep")
|
||||||
|
|
||||||
def load_compilers(self) -> Dict[str, AbstractCommandCompiler]:
|
def load_compilers(self) -> Dict[str, AbstractCommandCompiler]:
|
||||||
return {
|
return {
|
||||||
"wait": WaitCompiler(self._logger)
|
"sleep": SleepCompiler(self._logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
Loading…
Reference in New Issue
Block a user