mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 19:21:31 +00:00
Remove subprocess spawning stuff from YamlFSM for SRP
This commit is contained in:
parent
d71a25e30a
commit
1beb419b09
@ -34,11 +34,12 @@ class YamlFSM(FSMBase):
|
||||
for json_obj in self.config[array]:
|
||||
what(json_obj)
|
||||
|
||||
def patch_config_callbacks(self, json_obj):
|
||||
@staticmethod
|
||||
def patch_config_callbacks(json_obj):
|
||||
topatch = ('on_enter', 'on_exit', 'prepare', 'before', 'after')
|
||||
for key in json_obj:
|
||||
if key in topatch:
|
||||
json_obj[key] = partial(self.run, json_obj[key])
|
||||
json_obj[key] = partial(run_command_async, json_obj[key])
|
||||
|
||||
def subscribe_and_remove_predicates(self, json_obj):
|
||||
for key in json_obj:
|
||||
@ -47,17 +48,17 @@ class YamlFSM(FSMBase):
|
||||
self.subscribe_predicate(
|
||||
json_obj['trigger'],
|
||||
partial(
|
||||
self.statuscode_is_zero,
|
||||
command_statuscode_is_zero,
|
||||
predicate
|
||||
)
|
||||
)
|
||||
with suppress(KeyError):
|
||||
json_obj.pop('predicates')
|
||||
|
||||
@staticmethod
|
||||
def run(command, event):
|
||||
|
||||
def run_command_async(command, event):
|
||||
Popen(command, shell=True)
|
||||
|
||||
@staticmethod
|
||||
def statuscode_is_zero(command):
|
||||
|
||||
def command_statuscode_is_zero(command):
|
||||
return run(command, shell=True).returncode == 0
|
||||
|
Loading…
Reference in New Issue
Block a user