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

* 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>
(cherry picked from commit 739ca737f1)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2022-06-15 10:58:04 +02:00 committed by GitHub
commit eafcdfbceb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 5 deletions

View file

@ -205,11 +205,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
@ -235,7 +235,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: