From feb08d9a84a9305017d2b1dd945c783de94a3868 Mon Sep 17 00:00:00 2001 From: _srsh_ Date: Wed, 29 Jun 2016 09:12:04 +0200 Subject: [PATCH] module was failing on python 2.7 after last update (#2459) --- packaging/language/maven_artifact.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packaging/language/maven_artifact.py b/packaging/language/maven_artifact.py index 6f6454fb590..f5a88c7b220 100644 --- a/packaging/language/maven_artifact.py +++ b/packaging/language/maven_artifact.py @@ -26,6 +26,7 @@ import os import hashlib import sys import posixpath +import urlparse from ansible.module_utils.basic import * from ansible.module_utils.urls import * try: @@ -231,9 +232,9 @@ class MavenDownloader: def _request(self, url, failmsg, f): url_to_use = url - parsed_url = urlparse.urlparse(url) + parsed_url = urlparse(url) if parsed_url.scheme=='s3': - parsed_url = urlparse.urlparse(url) + parsed_url = urlparse(url) bucket_name = parsed_url.netloc[:parsed_url.netloc.find('.')] key_name = parsed_url.path[1:] client = boto3.client('s3',aws_access_key_id=self.module.params.get('username', ''), aws_secret_access_key=self.module.params.get('password', '')) @@ -332,8 +333,10 @@ def main(): ) ) - - parsed_url = urlparse.urlparse(module.params["repository_url"]) + try: + parsed_url = urlparse(module.params["repository_url"]) + except AttributeError as e: + module.fail_json(msg='url parsing went wrong %s' % e) if parsed_url.scheme=='s3' and not HAS_BOTO: module.fail_json(msg='boto3 required for this module, when using s3:// repository URLs') @@ -384,4 +387,4 @@ def main(): if __name__ == '__main__': - main() + main() \ No newline at end of file