[PR #9171/152339a8 backport][stable-10] gio_mime: fix bug when looking for version (#9177)
gio_mime: fix bug when looking for version (#9171)
* gio_mime: fix bug when looking for version
* add changelog frag
(cherry picked from commit 152339a8f9
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
pull/9182/head
parent
653ae1b48a
commit
0ff52abfdd
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- gio_mime - fix command line when determining version of ``gio`` (https://github.com/ansible-collections/community.general/pull/9171, https://github.com/ansible-collections/community.general/issues/9158).
|
|
@ -12,8 +12,9 @@ from ansible_collections.community.general.plugins.module_utils.cmd_runner impor
|
|||
def gio_mime_runner(module, **kwargs):
|
||||
return CmdRunner(
|
||||
module,
|
||||
command=['gio', 'mime'],
|
||||
command=['gio'],
|
||||
arg_formats=dict(
|
||||
mime=cmd_runner_fmt.as_fixed('mime'),
|
||||
mime_type=cmd_runner_fmt.as_list(),
|
||||
handler=cmd_runner_fmt.as_list(),
|
||||
version=cmd_runner_fmt.as_fixed('--version'),
|
||||
|
@ -29,5 +30,5 @@ def gio_mime_get(runner, mime_type):
|
|||
out = out.splitlines()[0]
|
||||
return out.split()[-1]
|
||||
|
||||
with runner("mime_type", output_process=process) as ctx:
|
||||
with runner("mime mime_type", output_process=process) as ctx:
|
||||
return ctx.run(mime_type=mime_type)
|
||||
|
|
|
@ -108,12 +108,11 @@ class GioMime(ModuleHelper):
|
|||
def __run__(self):
|
||||
check_mode_return = (0, 'Module executed in check mode', '')
|
||||
if self.vars.has_changed:
|
||||
with self.runner.context(args_order=["mime_type", "handler"], check_mode_skip=True, check_mode_return=check_mode_return) as ctx:
|
||||
with self.runner.context(args_order="mime mime_type handler", check_mode_skip=True, check_mode_return=check_mode_return) as ctx:
|
||||
rc, out, err = ctx.run()
|
||||
self.vars.stdout = out
|
||||
self.vars.stderr = err
|
||||
if self.verbosity >= 4:
|
||||
self.vars.run_info = ctx.run_info
|
||||
self.vars.set("run_info", ctx.run_info, verbosity=4)
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
changed: true
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/gio, mime, --version]
|
||||
- command: [/testbin/gio, --version]
|
||||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
|
||||
rc: 0
|
||||
out: "2.80.0\n"
|
||||
|
@ -40,7 +40,7 @@
|
|||
skip: test helper does not support check mode yet
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/gio, mime, --version]
|
||||
- command: [/testbin/gio, --version]
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: "2.80.0\n"
|
||||
|
@ -65,7 +65,7 @@
|
|||
changed: false
|
||||
mocks:
|
||||
run_command:
|
||||
- command: [/testbin/gio, mime, --version]
|
||||
- command: [/testbin/gio, --version]
|
||||
environ: *env-def
|
||||
rc: 0
|
||||
out: "2.80.0\n"
|
||||
|
|
Loading…
Reference in New Issue