Skip to content

Commit

Permalink
Update antsibull/docs_parsing/ansible_doc.py
Browse files Browse the repository at this point in the history
Co-authored-by: Toshio Kuratomi <[email protected]>
  • Loading branch information
felixfontein and abadger authored Jun 22, 2021
1 parent e9bdeb7 commit a1f54bd
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions antsibull/docs_parsing/ansible_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,19 +208,10 @@ def get_collection_metadata(venv: t.Union['VenvRunner', 'FakeVenvRunner'],
def get_ansible_core_version(venv: t.Union['VenvRunner', 'FakeVenvRunner'],
env: t.Dict[str, str],
) -> PypiVer:
venv_ansible = venv.get_command('ansible')
ansible_version_cmd = venv_ansible('--version', _env=env)
output = ansible_version_cmd.stdout.decode('utf-8', errors='surrogateescape')
first_line = output.splitlines()[0]
# `ansible 2.10.0`
m = re.match(r'^ansible ([^[ ]+)', first_line)
if m:
return PypiVer(m.group(1))
# `ansible [core 2.12.0.dev0] (devel cd8e3a2208) last updated 2021/05/19 08:35:55 (GMT +200)`
m = re.match(r'^ansible \[[^]]+ ([^]]+)\]', first_line)
if m:
return PypiVer(m.group(1))
raise ParsingError(f'Cannot interpret first line of ansible --version output: "{first_line}"')
venv_python = venv.get_command('python')
ansible_version_cmd = venv_python('-c', 'import ansible.release; print(ansible.release.__version__)', _env=env)
output = ansible_version_cmd.stdout.decode('utf-8', errors='surrogateescape').strip()
return PypiVer(output)


async def get_ansible_plugin_info(venv: t.Union['VenvRunner', 'FakeVenvRunner'],
Expand Down

0 comments on commit a1f54bd

Please sign in to comment.