Skip to content

Commit

Permalink
Fix unicode response handling from services.gragle.org
Browse files Browse the repository at this point in the history
Required only for python2, that's why additional condition was added
  • Loading branch information
yantonov committed Apr 14, 2023
1 parent 173943b commit 390f9c7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bin/gng
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ bootstrap_help() {
function parse_gradle_version() {
if command -v python &> /dev/null
then
python -c "import json,sys; obj=json.load(sys.stdin); print obj['version'];"
python_major_version=$(python --version 2>&1 >/dev/null | sed -E 's/.* ([0-9]+)(\.[0-9]+)?.*/\1/' | head -n 1)
if [ "$python_major_version" = "2" ]; then
python -c "import json,sys; obj=json.load(sys.stdin); print obj[unicode('version', 'utf-8')];"
else
python -c "import json,sys; obj=json.load(sys.stdin); print (obj['version']);"
fi
return
fi
if command -v python3 &> /dev/null
Expand Down

0 comments on commit 390f9c7

Please sign in to comment.