interpreter discovery message tweaks (#53155)

* fixes #53120 (doclink generator now understands devel)
* added hosts to some warnings
This commit is contained in:
Matt Davis 2019-02-28 17:53:55 -08:00 committed by GitHub
parent 35f5ca8295
commit 9c644d9bcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 14 deletions

View file

@ -117,11 +117,11 @@ def discover_interpreter(action, interpreter_name, discovery_mode, task_vars):
# FIXME: support comments in sivel's deprecation scanner so we can get reminded on this # FIXME: support comments in sivel's deprecation scanner so we can get reminded on this
if not is_silent: if not is_silent:
action._discovery_deprecation_warnings.append(dict( action._discovery_deprecation_warnings.append(dict(
msg="Distribution {0} {1} should use {2}, but is using " msg="Distribution {0} {1} on host {2} should use {3}, but is using "
"/usr/bin/python for backward compatibility with prior Ansible releases. " "/usr/bin/python for backward compatibility with prior Ansible releases. "
"A future Ansible release will default to using the discovered platform " "A future Ansible release will default to using the discovered platform "
"python for this host. See {3} for more information" "python for this host. See {4} for more information"
.format(distro, version, platform_interpreter, .format(distro, version, host, platform_interpreter,
get_versioned_doclink('reference_appendices/interpreter_discovery.html')), get_versioned_doclink('reference_appendices/interpreter_discovery.html')),
version='2.12')) version='2.12'))
return '/usr/bin/python' return '/usr/bin/python'
@ -131,15 +131,15 @@ def discover_interpreter(action, interpreter_name, discovery_mode, task_vars):
# sanity check to make sure we looked for it # sanity check to make sure we looked for it
if not is_silent: if not is_silent:
action._discovery_warnings \ action._discovery_warnings \
.append("Platform interpreter {0} is missing from bootstrap list" .append("Platform interpreter {0} on host {1} is missing from bootstrap list"
.format(platform_interpreter)) .format(platform_interpreter, host))
if not is_silent: if not is_silent:
action._discovery_warnings \ action._discovery_warnings \
.append("Distribution {0} {1} should use {2}, but is using {3}, since the " .append("Distribution {0} {1} on host {2} should use {3}, but is using {4}, since the "
"discovered platform python interpreter was not present. See {4} " "discovered platform python interpreter was not present. See {5} "
"for more information." "for more information."
.format(distro, version, platform_interpreter, found_interpreters[0], .format(distro, version, host, platform_interpreter, found_interpreters[0],
get_versioned_doclink('reference_appendices/interpreter_discovery.html'))) get_versioned_doclink('reference_appendices/interpreter_discovery.html')))
return found_interpreters[0] return found_interpreters[0]
@ -155,10 +155,10 @@ def discover_interpreter(action, interpreter_name, discovery_mode, task_vars):
if not is_silent: if not is_silent:
action._discovery_warnings \ action._discovery_warnings \
.append("Platform {0} is using the discovered Python interpreter at {1}, but future installation of " .append("Platform {0} on host {1} is using the discovered Python interpreter at {2}, but future installation of "
"another Python interpreter could change this. See {2} " "another Python interpreter could change this. See {3} "
"for more information." "for more information."
.format(platform_type, found_interpreters[0], .format(platform_type, host, found_interpreters[0],
get_versioned_doclink('reference_appendices/interpreter_discovery.html'))) get_versioned_doclink('reference_appendices/interpreter_discovery.html')))
return found_interpreters[0] return found_interpreters[0]

View file

@ -128,11 +128,18 @@ def get_versioned_doclink(path):
if path.startswith('/'): if path.startswith('/'):
path = path[1:] path = path[1:]
split_ver = ansible_version.split('.') split_ver = ansible_version.split('.')
if len(split_ver) < 2: if len(split_ver) < 3:
raise RuntimeError('invalid version ({0})'.format(ansible_version)) raise RuntimeError('invalid version ({0})'.format(ansible_version))
major_minor = '{0}.{1}'.format(split_ver[0], split_ver[1]) doc_version = '{0}.{1}'.format(split_ver[0], split_ver[1])
return '{0}{1}/{2}'.format(base_url, major_minor, path) # check to see if it's a X.Y.0 non-rc prerelease or dev release, if so, assume devel (since the X.Y doctree
# isn't published until beta-ish)
if split_ver[2].startswith('0'):
# exclude rc; we should have the X.Y doctree live by rc1
if any((pre in split_ver[2]) for pre in ['a', 'b']) or len(split_ver) > 3 and 'dev' in split_ver[3]:
doc_version = 'devel'
return '{0}{1}/{2}'.format(base_url, doc_version, path)
except Exception as ex: except Exception as ex:
return '(unable to create versioned doc link for path {0}: {1})'.format(path, to_native(ex)) return '(unable to create versioned doc link for path {0}: {1})'.format(path, to_native(ex))