From 5f0dc2b90fef8cf035ee9115570b70041ea37108 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 27 Apr 2016 07:17:05 -0700 Subject: [PATCH] Some beginning python3 porting for modules which have unittests --- lib/ansible/modules/cloud/docker/docker.py | 7 ++++++- lib/ansible/modules/packaging/os/apt.py | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/docker/docker.py b/lib/ansible/modules/cloud/docker/docker.py index 7efde161aa9..87c9df2de55 100644 --- a/lib/ansible/modules/cloud/docker/docker.py +++ b/lib/ansible/modules/cloud/docker/docker.py @@ -528,7 +528,12 @@ import sys import json import os import shlex -from urlparse import urlparse +try: + from urlparse import urlparse +except ImportError: + # python3 + from urllib.parse import urlparse + try: import docker.client import docker.utils diff --git a/lib/ansible/modules/packaging/os/apt.py b/lib/ansible/modules/packaging/os/apt.py index 796d1010c95..6f116907da8 100644 --- a/lib/ansible/modules/packaging/os/apt.py +++ b/lib/ansible/modules/packaging/os/apt.py @@ -487,7 +487,8 @@ def install_deb(m, debs, cache, force, install_recommends, allow_unauthenticated # to install so they're all done in one shot deps_to_install.extend(pkg.missing_deps) - except Exception, e: + except Exception: + e = get_exception() m.fail_json(msg="Unable to install package: %s" % str(e)) # and add this deb to the list of packages to install @@ -643,7 +644,8 @@ def download(module, deb): f.write(data) f.close() deb = package - except Exception, e: + except Exception: + e = get_exception() module.fail_json(msg="Failure downloading %s, %s" % (deb, e)) return deb