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
This commit is contained in:
Vitaly Gridnev 2016-08-26 01:05:51 +03:00
parent 90bc7ccbda
commit f95a8051ca

View File

@ -12,7 +12,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
"true" '''\' "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" interpreter="python3"
else else
interpreter="python" interpreter="python"