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

plugins/tower.py: Use urllib.parse rather than urlparse #3416

Merged
merged 1 commit into from
Mar 18, 2019

Conversation

Spredzy
Copy link
Contributor

@Spredzy Spredzy commented Mar 14, 2019

SUMMARY

urlparse does not exist in python3, it has been replaced by urllib.parse

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • API
AWX VERSION
  • devel
ADDITIONAL INFORMATION
  • N/A

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@AlanCoding
Copy link
Member

This is quite similar in nature to:

#3305

We have not committed to supporting inventory updates via scripts in python3 virtual environments. This shouldn't be a formal test objective.

We will absolutely support inventory updates via plugins in python3 virtual environments, including the default virtual environment.

However, it remains extremely important that tower.py continues to work in python2.

$ python
Python 2.7.11 (default, Oct 17 2016, 14:59:40) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib.parse import urljoin
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named parse

At best, you could do a conditional import. I wouldn't object to that, but it would still be officially unsupported to run it in python3.

@ryanpetrello
Copy link
Contributor

I'm not against just saying this one only works in py2, personally (especially if Tower inv plugins are on by default after @AlanCoding's PR merges).

@@ -34,7 +34,7 @@
import json
import requests
from requests.auth import HTTPBasicAuth
from urlparse import urljoin
from urllib.parse import urljoin
Copy link
Contributor

@ryanpetrello ryanpetrello Mar 14, 2019

Choose a reason for hiding this comment

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

If we do this, we should at least make this 2/3 compatible:

try:
    from urlparse import urljoin
except ImportError:
    from urllib.parse import urljoin

@wenottingham
Copy link
Contributor

We have not committed to supporting inventory updates via scripts in python3 virtual environments. This shouldn't be a formal test objective.

We'll have either python2 or python3 for the ansible-inventory environment depending on OS; ergo, I would expect customer scripts to potentially be run in either depending on their deployment platform.

urlparse does not exist in python3, it has been replaced by urllib.parse

Signed-off-by: Yanis Guenane <yguenane@redhat.com>
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 9ab7752 into ansible:devel Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants