diff --git a/contrib/datawave-quickstart/bin/query.sh b/contrib/datawave-quickstart/bin/query.sh index ced895a3d66..d49aa64b4f1 100644 --- a/contrib/datawave-quickstart/bin/query.sh +++ b/contrib/datawave-quickstart/bin/query.sh @@ -131,21 +131,8 @@ function setQueryIdFromResponse() { } function prettyPrintJson() { - local PY=$( which python ) - if [ -n "${PY}" ] ; then - echo "${1}" | ${PY} -c 'from __future__ import print_function;import sys,json;data=json.loads(sys.stdin.read()); print(json.dumps(data, indent=2, sort_keys=True))' - local exitStatus=$? - echo - if [ "${exitStatus}" != "0" ] ; then - printRawResponse "${1}" - warn "Python encountered error. Printed response without formatting" - echo - fi - else - printRawResponse "${1}" - warn "Couldn't find python in your environment. Json response was printed without formatting" - echo - fi + PY_CMD='from __future__ import print_function; import sys,json; data=json.loads(sys.stdin.read()); print(json.dumps(data, indent=2, sort_keys=True))' + echo "${1}" | ( python3 -c "${PY_CMD}" 2>/dev/null || python2 -c "${PY_CMD}" 2>/dev/null ) || ( warn "Python encountered error. Printed response without formatting" && printRawResponse "${1}" ) } function printRawResponse() { diff --git a/contrib/datawave-quickstart/bin/services/datawave/ingest-examples/tvmaze-api-query.sh b/contrib/datawave-quickstart/bin/services/datawave/ingest-examples/tvmaze-api-query.sh index af1da19187e..69cf2d47fa5 100755 --- a/contrib/datawave-quickstart/bin/services/datawave/ingest-examples/tvmaze-api-query.sh +++ b/contrib/datawave-quickstart/bin/services/datawave/ingest-examples/tvmaze-api-query.sh @@ -38,10 +38,11 @@ TVMAZE_RESPONSE_STATUS=$( echo ${CURL_RESPONSE} | tr -d '\n' | sed -e 's/.*HTTP_ [ "${TVMAZE_RESPONSE_STATUS}" != "200" ] && error "api.tvmaze.com returned invalid response status: ${TVMAZE_RESPONSE_STATUS}" && exit 1 [ -z "${TVMAZE_RESPONSE_BODY}" ] && error "Response body is empty!" && exit 1 +PY_CMD='from __future__ import print_function; import sys,json; data=json.loads(sys.stdin.read()); print(json.dumps(data, indent=2, sort_keys=True))' if [ "${PRETTY}" == true ] ; then - echo "${TVMAZE_RESPONSE_BODY}" | python -c 'from __future__ import print_function;import sys,json;data=json.loads(sys.stdin.read()); print(json.dumps(data, indent=2, sort_keys=True))' + echo "${TVMAZE_RESPONSE_BODY}" | ( python3 -c "${PY_CMD}" 2>/dev/null || python2 -c "${PY_CMD}" 2>/dev/null ) || ( warn "Unable to pretty print, Python not detected" && echo "${TVMAZE_RESPONSE_BODY}" ) else - echo "${TVMAZE_RESPONSE_BODY}" + echo "${TVMAZE_RESPONSE_BODY}" fi exit 0 \ No newline at end of file diff --git a/contrib/datawave-quickstart/docker/Dockerfile b/contrib/datawave-quickstart/docker/Dockerfile index 3d2e2bd238f..7396b0c7527 100644 --- a/contrib/datawave-quickstart/docker/Dockerfile +++ b/contrib/datawave-quickstart/docker/Dockerfile @@ -35,7 +35,7 @@ COPY . /opt/datawave # Install dependencies, configure password-less/zero-prompt SSH... -RUN dnf -y install gcc-c++ openssl openssh openssh-server openssh-clients openssl-libs which bc wget git java-11-openjdk-devel iproute && \ +RUN dnf -y install gcc-c++ openssl python3 openssh openssh-server openssh-clients openssl-libs which bc wget git java-11-openjdk-devel iproute && \ dnf clean all && \ ssh-keygen -q -N "" -t rsa -f ~/.ssh/id_rsa && \ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys && \