Skip to content
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

Ensure compatibility with python 2.7 / ansible 2.9 #19

Merged

Conversation

guidograzioli
Copy link
Member

@guidograzioli guidograzioli commented Sep 30, 2023

  • Convert f-strings to str.format()
  • load_file_common_args has path in params
  • python 2.7 urllib open has no context manager

Fix #18
Fix #19 (8682417)

@guidograzioli guidograzioli added the bugfixes Fixes that resolve issues. SHOULD not be used for minor enhancements label Sep 30, 2023
@sabre1041
Copy link
Contributor

sabre1041 commented Oct 2, 2023

When testing with Python 2.7 and Ansible 2.9, the following warnings are shown:

  • [WARNING]: The value 5.5 (type float) in a string field was converted to u'5.5' (type string). If this does not look like what you expect, quote the entire value to ensure it does not change.

Using the product_download module results in the following error:

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error Downloading Red Hat JBoss Web Server 5.5.0 Documentation: addinfourl instance has no attribute '__exit__'"}

To be fair, the error is a bit unrelated to the formatting change noted in this PR and is mostly due to the removal of the requests dependency.

If you would be able to look into the warnings, I can take a look at the error as it is a side effect of some of the efforts that I spearheaded

@guidograzioli
Copy link
Member Author

[WARNING]: The value 5.5 (type float) in a string field was converted to u'5.5' (type string). If this does not look like what you expect, quote the entire value to ensure it does not change.

The above seems to depend on the calling playbook passing version: 5.5 instead of version: '5.5', since the warning happens at call time, we cannot do anything in the module

@guidograzioli
Copy link
Member Author

Can you share your playbook, I am now hitting this: ansible/ansible#72587
on:

(2.9) [guido@fedora common]$ ansible --version
/home/guido/Development/virtualenv/2.9/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py:44: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
  from cryptography.exceptions import InvalidSignature
ansible 2.9.27.post0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/guido/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/guido/Development/virtualenv/2.9/lib/python2.7/site-packages/ansible
  executable location = /home/guido/Development/virtualenv/2.9/bin/ansible
  python version = 2.7.18 (default, May 25 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)]

@guidograzioli
Copy link
Member Author

Latest commit fixes load_file_common_arguments in stable-2.9 reading path or dest only from module params, not as keyword.

@guidograzioli
Copy link
Member Author

@sabre1041 anything left here? or we can merge?

Copy link
Contributor

@sabre1041 sabre1041 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sabre1041 sabre1041 merged commit 5c0bf90 into ansible-middleware:main Oct 11, 2023
12 checks passed
@guidograzioli guidograzioli changed the title Convert f-strings to str.format() Ensure compatibility with python 2.7 / ansible 2.9 Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfixes Fixes that resolve issues. SHOULD not be used for minor enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python 2 Support in JBossNetworkAPI
2 participants