New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanups to the common.sys_info API #50420

Merged
merged 1 commit into from Jan 4, 2019

Conversation

Projects
None yet
3 participants
@abadger
Copy link
Member

abadger commented Dec 31, 2018

  • Move get_all_subclasses out of sys_info as it is unrelated to system
    information.
  • get_all_subclasses now returns a set() instead of a list.
  • Don't port get_platform to sys_info as it is deprecated. Code using
    the common API should just use platform.system() directly.
  • Rename load_platform_subclass() to get_platform_subclass and do not
    instantiate the rturned class.
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lib/ansible/module_utils/common/sys_info.py

ADDITIONAL INFORMATION

Changes to the common.sys_info API that should be made before 2.8.x. sys_info is new in 2.8 so these changes can still be made without a deprecation period.

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Dec 31, 2018

The test ansible-test sanity --test pylint [explain] failed with 1 error:

lib/ansible/module_utils/basic.py:185:0: syntax-error trailing comma not allowed without surrounding parentheses (<unknown>, line 185)

The test ansible-test sanity --test ansible-doc --python 2.7 [explain] failed with the error:

Command "ansible-doc -t cache jsonfile memcached memory mongodb pickle redis yaml" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: trailing comma not allowed without surrounding parentheses (basic.py, line 185)

The test ansible-test sanity --test ansible-doc --python 3.5 [explain] failed with the error:

Command "ansible-doc -t cache jsonfile memcached memory mongodb pickle redis yaml" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: trailing comma not allowed without surrounding parentheses (basic.py, line 185)

The test ansible-test sanity --test ansible-doc --python 2.6 [explain] failed with the error:

Command "ansible-doc -t cache jsonfile memcached memory mongodb pickle redis yaml" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: trailing comma not allowed without surrounding parentheses (basic.py, line 185)

The test ansible-test sanity --test ansible-doc --python 3.7 [explain] failed with the error:

Command "ansible-doc -t cache jsonfile memcached memory mongodb pickle redis yaml" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: trailing comma not allowed without surrounding parentheses (basic.py, line 185)

The test ansible-test sanity --test ansible-doc --python 3.6 [explain] failed with the error:

Command "ansible-doc -t cache jsonfile memcached memory mongodb pickle redis yaml" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: trailing comma not allowed without surrounding parentheses (basic.py, line 185)

The test ansible-test sanity --test docs-build [explain] failed with the error:

Command "/usr/bin/python test/sanity/code-smell/docs-build.py" returned exit status 1.
>>> Standard Error
Command 'make singlehtmldocs' failed with status code: 2
--> Standard Output
cat _themes/srtd/static/css/theme.css | sed -e 's/^[ 	]*//g; s/[ 	]*$//g; s/\([:{;,]\) /\1/g; s/ {/{/g; s/\/\*.*\*\///g; /^$/d' | sed -e :a -e '$!N; s/\n\(.\)/\1/; ta' > _themes/srtd/static/css/theme.min.css
PYTHONPATH=../../lib ../bin/dump_config.py --template-file=../templates/config.rst.j2 --output-dir=rst/reference_appendices/ -d ../../lib/ansible/config/base.yml
mkdir -p rst/cli
PYTHONPATH=../../lib ../bin/generate_man.py --template-file=../templates/cli_rst.j2 --output-dir=rst/cli/ --output-format rst ../../lib/ansible/cli/*.py
Makefile:83: recipe for target 'cli' failed
--> Standard Error
Traceback (most recent call last):
  File "../bin/generate_man.py", line 253, in <module>
    allvars[cli_name] = opts_docs(cli_class_name, cli_name)
  File "../bin/generate_man.py", line 104, in opts_docs
    fromlist=[cli_class_name]), cli_class_name)
  File "/root/ansible/lib/ansible/cli/__init__.py", line 41, in <module>
    from ansible.parsing.dataloader import DataLoader
  File "/root/ansible/lib/ansible/parsing/dataloader.py", line 17, in <module>
    from ansible.module_utils.basic import is_executable
  File "/root/ansible/lib/ansible/module_utils/basic.py", line 185
    from ansible.modult_utils.common._utils import get_all_subclasses as _get_all_subclasses,
                                                  ^
SyntaxError: trailing comma not allowed without surrounding parentheses
make: *** [cli] Error 1

click here for bot help

@ansibot ansibot added needs_revision and removed core_review labels Dec 31, 2018

@abadger abadger force-pushed the abadger:module_utils-sys_info-more-refactor branch from 098895a to cf643ee Dec 31, 2018

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Dec 31, 2018

The test ansible-test sanity --test pylint [explain] failed with 3 errors:

lib/ansible/module_utils/basic.py:185:0: ansible-bad-module-import Import external package or ansible.module_utils not ansible.modult_utils.common._utils
lib/ansible/module_utils/basic.py:302:22: undefined-variable Undefined variable 'subclass'
lib/ansible/module_utils/basic.py:302:40: undefined-variable Undefined variable 'subclass'

The test ansible-test sanity --test ansible-doc --python 2.6 [explain] failed with the error:

Command "ansible-doc -t cache jsonfile memcached memory mongodb pickle redis yaml" returned exit status 250.
>>> Standard Error
/root/ansible/bin/ansible-doc:95: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
  msg = e.message
ERROR! Unexpected Exception, this is probably a bug: No module named modult_utils.common._utils

The test ansible-test sanity --test ansible-doc --python 2.7 [explain] failed with the error:

Command "ansible-doc -t cache jsonfile memcached memory mongodb pickle redis yaml" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: No module named modult_utils.common._utils

The test ansible-test sanity --test ansible-doc --python 3.5 [explain] failed with the error:

Command "ansible-doc -t cache jsonfile memcached memory mongodb pickle redis yaml" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: No module named 'ansible.modult_utils'

The test ansible-test sanity --test ansible-doc --python 3.6 [explain] failed with the error:

Command "ansible-doc -t cache jsonfile memcached memory mongodb pickle redis yaml" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: No module named 'ansible.modult_utils'

The test ansible-test sanity --test ansible-doc --python 3.7 [explain] failed with the error:

Command "ansible-doc -t cache jsonfile memcached memory mongodb pickle redis yaml" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: No module named 'ansible.modult_utils'

The test ansible-test sanity --test docs-build [explain] failed with the error:

Command "/usr/bin/python test/sanity/code-smell/docs-build.py" returned exit status 1.
>>> Standard Error
Command 'make singlehtmldocs' failed with status code: 2
--> Standard Output
cat _themes/srtd/static/css/theme.css | sed -e 's/^[ 	]*//g; s/[ 	]*$//g; s/\([:{;,]\) /\1/g; s/ {/{/g; s/\/\*.*\*\///g; /^$/d' | sed -e :a -e '$!N; s/\n\(.\)/\1/; ta' > _themes/srtd/static/css/theme.min.css
PYTHONPATH=../../lib ../bin/dump_config.py --template-file=../templates/config.rst.j2 --output-dir=rst/reference_appendices/ -d ../../lib/ansible/config/base.yml
mkdir -p rst/cli
PYTHONPATH=../../lib ../bin/generate_man.py --template-file=../templates/cli_rst.j2 --output-dir=rst/cli/ --output-format rst ../../lib/ansible/cli/*.py
Makefile:83: recipe for target 'cli' failed
--> Standard Error
Traceback (most recent call last):
  File "../bin/generate_man.py", line 253, in <module>
    allvars[cli_name] = opts_docs(cli_class_name, cli_name)
  File "../bin/generate_man.py", line 104, in opts_docs
    fromlist=[cli_class_name]), cli_class_name)
  File "/root/ansible/lib/ansible/cli/__init__.py", line 41, in <module>
    from ansible.parsing.dataloader import DataLoader
  File "/root/ansible/lib/ansible/parsing/dataloader.py", line 17, in <module>
    from ansible.module_utils.basic import is_executable
  File "/root/ansible/lib/ansible/module_utils/basic.py", line 185, in <module>
    from ansible.modult_utils.common._utils import get_all_subclasses as _get_all_subclasses
ModuleNotFoundError: No module named 'ansible.modult_utils'
make: *** [cli] Error 1

click here for bot help

@abadger abadger force-pushed the abadger:module_utils-sys_info-more-refactor branch 2 times, most recently from 3b4b272 to 7a84398 Dec 31, 2018

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Jan 1, 2019

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

lib/ansible/module_utils/basic.py:302:22: undefined-variable Undefined variable 'subclass'
lib/ansible/module_utils/basic.py:302:40: undefined-variable Undefined variable 'subclass'

The test ansible-test sanity --test docs-build [explain] failed with 1 error:

docs/docsite/rst/index.rst:0:0: unknown: /root/ansible/lib/ansible/module_utils/basic.py:docstring of ansible.module_utils.basic.get_platform:: WARNING: py:class reference target not found: NativeString

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/module_utils/basic.py:280:1: E302 expected 2 blank lines, found 1

click here for bot help

@abadger abadger force-pushed the abadger:module_utils-sys_info-more-refactor branch 5 times, most recently from 8d86bac to 1dc9ae6 Jan 1, 2019

Cleanups to the common.sys_info API
* Move get_all_subclasses out of sys_info as it is unrelated to system
  information.
* get_all_subclasses now returns a set() instead of a list.
* Don't port get_platform to sys_info as it is deprecated.  Code using
  the common API should just use platform.system() directly.
* Rename load_platform_subclass() to get_platform_subclass and do not
  instantiate the rturned class.
* Test the compat shims in module_utils/basic.py separately from the new
  API in module_utils/common/sys_info.py and module_utils/common/_utils.py

@abadger abadger force-pushed the abadger:module_utils-sys_info-more-refactor branch from 1dc9ae6 to 5770485 Jan 2, 2019

@sivel sivel removed needs_triage labels Jan 3, 2019

@ansibot ansibot added core_review and removed needs_revision labels Jan 3, 2019

@abadger abadger merged commit 5844c8c into ansible:devel Jan 4, 2019

1 check passed

Shippable Run 100539 status is SUCCESS.
Details

@abadger abadger deleted the abadger:module_utils-sys_info-more-refactor branch Jan 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment