mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-23 00:31: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]:
|
for json_obj in self.config[array]:
|
||||||
what(json_obj)
|
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')
|
topatch = ('on_enter', 'on_exit', 'prepare', 'before', 'after')
|
||||||
for key in json_obj:
|
for key in json_obj:
|
||||||
if key in topatch:
|
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):
|
def subscribe_and_remove_predicates(self, json_obj):
|
||||||
for key in json_obj:
|
for key in json_obj:
|
||||||
@ -47,17 +48,17 @@ class YamlFSM(FSMBase):
|
|||||||
self.subscribe_predicate(
|
self.subscribe_predicate(
|
||||||
json_obj['trigger'],
|
json_obj['trigger'],
|
||||||
partial(
|
partial(
|
||||||
self.statuscode_is_zero,
|
command_statuscode_is_zero,
|
||||||
predicate
|
predicate
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
with suppress(KeyError):
|
with suppress(KeyError):
|
||||||
json_obj.pop('predicates')
|
json_obj.pop('predicates')
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def run(command, event):
|
|
||||||
Popen(command, shell=True)
|
|
||||||
|
|
||||||
@staticmethod
|
def run_command_async(command, event):
|
||||||
def statuscode_is_zero(command):
|
Popen(command, shell=True)
|
||||||
return run(command, shell=True).returncode == 0
|
|
||||||
|
|
||||||
|
def command_statuscode_is_zero(command):
|
||||||
|
return run(command, shell=True).returncode == 0
|
||||||
|
Loading…
Reference in New Issue
Block a user