cmd_runner: add __call__ method to invoke context (#4791)

* cmd_runner: add __call__ method to invoke context

* change xfconf to use the callable form

* add changelog fragment

* Update changelogs/fragments/4791-cmd-runner-callable.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Alexei Znamensky 2022-06-15 18:06:26 +12:00 committed by GitHub
commit 739ca737f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 5 deletions

View file

@ -209,11 +209,11 @@ class XFConfProperty(StateModuleHelper):
return result
def _get(self):
with self.runner.context('channel property', output_process=self.process_command_output) as ctx:
with self.runner('channel property', output_process=self.process_command_output) as ctx:
return ctx.run()
def state_absent(self):
with self.runner.context('channel property reset', check_mode_skip=True) as ctx:
with self.runner('channel property reset', check_mode_skip=True) as ctx:
ctx.run(reset=True)
self.vars.value = None
@ -239,7 +239,7 @@ class XFConfProperty(StateModuleHelper):
isinstance(self.vars.previous_value, list) or \
values_len > 1
with self.runner.context('channel property create force_array values_and_types', check_mode_skip=True) as ctx:
with self.runner('channel property create force_array values_and_types', check_mode_skip=True) as ctx:
ctx.run(create=True, force_array=self.vars.is_array, values_and_types=(self.vars.value, value_type))
if not self.vars.is_array: