From f95a8051ca248044cb1655b19ef22b94a2c337ff Mon Sep 17 00:00:00 2001 From: Vitaly Gridnev Date: Fri, 26 Aug 2016 01:05:51 +0300 Subject: [PATCH] Validate that python3 is ready for loguserdata By default, ubuntu trusty images has python3 executable in path, but we can't use that for executing loguserdata script, because pkg_resources can't be imported. Now it's proposed to try importing pkg_resources for validating readiness of python3 for executing this script. If pkg_resources can't be imported there is no other choice except using python2. Change-Id: Icb4f58630016874eb40dd77590469fc5de6287e4 Closes-bug: 1617069 --- heat/cloudinit/loguserdata.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/heat/cloudinit/loguserdata.py b/heat/cloudinit/loguserdata.py index 7d0dbae461..e02a59baeb 100755 --- a/heat/cloudinit/loguserdata.py +++ b/heat/cloudinit/loguserdata.py @@ -12,7 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. "true" '''\' -if hash python3 2>/dev/null; then +# NOTE(vgridnev): ubuntu trusty by default has python3, +# but pkg_resources can't be imported. +echo "import pkg_resources" | python3 2>/dev/null +has_py3=$? +if [ $has_py3 = 0 ]; then interpreter="python3" else interpreter="python"