feat: add support for python3

- Use jq where possible
- Drop unused function (no usage across entire codebase nor in any github repository

Closes #3689
This commit is contained in:
Jose Diaz-Gonzalez
2019-09-17 03:06:00 -04:00
parent 7bd4d32cb3
commit b4e95fe0d5
9 changed files with 20 additions and 26 deletions

View File

@@ -42,7 +42,7 @@ def main():
download_urls['downloads/' + version['filename']] = version['download_url']
for filename, download_url in download_urls.items():
print "downloading", filename
print("downloading {0}".format(filename))
download_file(filename, download_url)
upload_file(filename)

View File

@@ -1,11 +1,15 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
import cgi
import json
import os
import re
import SimpleHTTPServer
import SocketServer
try:
import SimpleHTTPServer
import SocketServer
except ImportError:
import http.server as SimpleHTTPServer
import socketserver as SocketServer
import subprocess
import sys
import threading
@@ -232,7 +236,7 @@ def main():
port = int(os.getenv('PORT', 2000))
httpd = SocketServer.TCPServer(("", port), GetHandler)
print "Listening on 0.0.0.0:{0}, CTRL+C to stop".format(port)
print("Listening on 0.0.0.0:{0}, CTRL+C to stop".format(port))
httpd.serve_forever()

4
debian/control vendored
View File

@@ -3,9 +3,9 @@ Version: 0.18.3
Section: web
Priority: optional
Architecture: amd64
Depends: locales, git, curl, man-db, netcat, sshcommand (>= 0.6.0), gliderlabs-sigil, docker-engine-cs (>= 1.13.0) | docker-engine (>= 1.13.0) | docker-io (>= 1.13.0) | docker.io (>= 1.13.0) | docker-ce (>= 1.13.0) | docker-ee (>= 1.13.0), net-tools, software-properties-common, procfile-util, python-software-properties | python3-software-properties, rsyslog, dos2unix
Depends: locales, git, curl, man-db, netcat, sshcommand (>= 0.6.0), gliderlabs-sigil, docker-engine-cs (>= 1.13.0) | docker-engine (>= 1.13.0) | docker-io (>= 1.13.0) | docker.io (>= 1.13.0) | docker-ce (>= 1.13.0) | docker-ee (>= 1.13.0), net-tools, software-properties-common, procfile-util, python-software-properties | python3-software-properties, rsyslog, dos2unix, jq
Recommends: herokuish (>= 0.3.4), parallel, dokku-update
Pre-Depends: nginx (>= 1.8.0) | openresty, dnsutils, cgroupfs-mount | cgroup-lite, plugn (>= 0.3.0), sudo, python2.7, debconf
Pre-Depends: nginx (>= 1.8.0) | openresty, dnsutils, cgroupfs-mount | cgroup-lite, plugn (>= 0.3.0), sudo, python | python2.7 | python3, debconf
Maintainer: Jose Diaz-Gonzalez <dokku@josediazgonzalez.com>
Description: Docker-powered PaaS that helps build and manage the lifecycle of applications
Dokku is an extensible, open source Platform as a Service

View File

@@ -10,3 +10,6 @@ dokku: hardening-no-relro
# Built golang binaries link to libc
dokku: missing-dependency-on-libc
# Temporary python dependency until #2247 is resolved
dokku: python-script-but-no-python-dep usr/share/dokku/contrib/dokku-installer.py

View File

@@ -17,7 +17,7 @@ get_phase_script() {
return 0
fi
get_json_value "scripts.dokku.${PHASE_SCRIPT_KEY}" <"$APP_JSON_FILE"
get_json_value ".scripts.dokku.${PHASE_SCRIPT_KEY}" <"$APP_JSON_FILE"
}
get_release_cmd() {

View File

@@ -923,24 +923,10 @@ internal_get_app_urls() {
get_json_value() {
declare desc="return value of provided json key from a json stream on stdin"
# JSON_NODE should be expresses as either a top-level object that has no children
# or in the format of json.node.path
# or in the format of .json.node.path
local JSON_NODE="$1"
local JSON_NODE=${JSON_NODE//\./\"][\"}
local JSON_NODE="[\"${JSON_NODE}\"]"
cat | python2.7 -c 'import json,sys;obj=json.load(sys.stdin);print json.dumps(obj'"${JSON_NODE}"').strip("\"")'
}
get_json_keys() {
declare desc="return space-separated list of json keys from json provided on stdin"
# JSON_NODE should be expressed as json.node.path and is expected to have children
local JSON_NODE="$1"
local JSON_NODE=${JSON_NODE//\./\"][\"}
local JSON_NODE="[\"${JSON_NODE}\"]"
if [[ "$JSON_NODE" == "[\"\"]" ]]; then
cat | python2.7 -c 'import json,sys;obj=json.load(sys.stdin);print " ".join(obj.keys())'
else
cat | python2.7 -c 'import json,sys;obj=json.load(sys.stdin);print " ".join(obj'"${JSON_NODE}"'.keys())'
fi
cat | jq -r "${JSON_NODE} | select (.!=null)" 2>/dev/null
}
strip_inline_comments() {

View File

@@ -40,7 +40,7 @@ for container in data:
container['Config']['Env'] = env
output.append(container)
print json.dumps(data, sort_keys=True, indent=4)
print(json.dumps(data, sort_keys=True, indent=4))
EOF
local CONTAINER_FILES="$(find "$DOKKU_ROOT/$APP" -maxdepth 1 -name "CONTAINER.*" -printf "%f\n" 2>/dev/null | sort -t . -k 2 -n | xargs)"

1
rpm.mk
View File

@@ -65,6 +65,7 @@ endif
--depends 'dos2unix' \
--depends 'git' \
--depends 'gliderlabs-sigil' \
--depends 'jq' \
--depends 'man-db' \
--depends 'nc' \
--depends 'nginx >= 1.8.0' \

View File

@@ -29,7 +29,7 @@ install_dependencies() {
sudo add-apt-repository -y ppa:nginx/stable
sudo apt-get update
sudo apt-get -qq -y install cgroupfs-mount dos2unix nginx
sudo apt-get -qq -y install cgroupfs-mount dos2unix jq nginx
sudo cp "${ROOT_DIR}/tests/dhparam.pem" /etc/nginx/dhparam.pem
sudo dpkg -i "${ROOT_DIR}/build/$HEROKUISH_PACKAGE_NAME" \