Skip to content

Commit

Permalink
Merge pull request #163 from gsunner/release-script-python3-compatibi…
Browse files Browse the repository at this point in the history
…lity

Release script python3 compatibility
  • Loading branch information
ukclivecox authored Jun 7, 2018
2 parents e624411 + aeba086 commit dcfc93d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
5 changes: 3 additions & 2 deletions core-builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ RUN \

# dependencies for release script
RUN \
# install env for python3
apt-get update -y && \
apt-get install -y python-pip && \
pip install pyyaml && \
apt-get install -y python3-pip && \
pip3 install pyyaml && \
apt-get remove -y --auto-remove && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /work
Expand Down
2 changes: 1 addition & 1 deletion core-builder/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DOCKER_IMAGE_NAME=seldonio/core-builder
DOCKER_IMAGE_VERSION=0.2
DOCKER_IMAGE_VERSION=0.3

build_docker_image:
docker build --force-rm=true -t $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION) .
Expand Down
2 changes: 1 addition & 1 deletion release
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ STARTUP_DIR="$( cd "$( dirname "$0" )" && pwd )"
docker run --rm -it \
-v ${HOME}/.m2:/root/.m2 \
-v "${STARTUP_DIR}":/work \
seldonio/core-builder:0.2 python release.py "$@"
seldonio/core-builder:0.3 python3 release.py "$@"

32 changes: 16 additions & 16 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

import yaml
import StringIO
from io import StringIO
import pprint
from subprocess import Popen, PIPE
import os
Expand All @@ -27,13 +27,13 @@ def dict_to_yaml(d):
return yaml.dump(d, default_flow_style=False)

def yaml_to_dict(yaml_data):
return yaml.load(StringIO.StringIO(yaml_data))
return yaml.load(StringIO(yaml_data))

def run_command(args, debug=False):
err, out = None, None
if debug:
print "cwd[{}]".format(os.getcwd())
print "Executing: " + repr(args)
print("cwd[{}]".format(os.getcwd()))
print("Executing: " + repr(args))
p = Popen(args, stdout=PIPE, stderr=PIPE)
if p.wait() == 0:
out = p.stdout.read()
Expand All @@ -51,23 +51,23 @@ def run_command(args, debug=False):
def update_pom_file(fpath, seldon_core_version, debug=False):
fpath = os.path.realpath(fpath)
if debug:
print "processing [{}]".format(fpath)
print("processing [{}]".format(fpath))
comp_dir_path = os.path.dirname(fpath)
os.chdir(comp_dir_path)
args = ["mvn", "versions:set", "-DnewVersion={seldon_core_version}".format(**locals())]
err, out = run_command(args, debug)
##pp(out)
##pp(err)
if err == None:
print "updated {fpath}".format(**locals())
print("updated {fpath}".format(**locals()))
else:
print "error {fpath}".format(**locals())
print err
print("error {fpath}".format(**locals()))
print(err)

def update_chart_yaml_file(fpath, seldon_core_version, debug=False):
fpath = os.path.realpath(fpath)
if debug:
print "processing [{}]".format(fpath)
print("processing [{}]".format(fpath))
f = open(fpath)
yaml_data = f.read()
f.close()
Expand All @@ -78,13 +78,13 @@ def update_chart_yaml_file(fpath, seldon_core_version, debug=False):
with open(fpath, 'w') as f:
f.write(dict_to_yaml(d))

print "updated {fpath}".format(**locals())
print("updated {fpath}".format(**locals()))


def update_values_yaml_file(fpath, seldon_core_version, debug=False):
fpath = os.path.realpath(fpath)
if debug:
print "processing [{}]".format(fpath)
print("processing [{}]".format(fpath))
f = open(fpath)
yaml_data = f.read()
f.close()
Expand All @@ -97,7 +97,7 @@ def update_values_yaml_file(fpath, seldon_core_version, debug=False):
with open(fpath, 'w') as f:
f.write(dict_to_yaml(d))

print "updated {fpath}".format(**locals())
print("updated {fpath}".format(**locals()))

def update_core_jsonnet(fpath, seldon_core_version, debug=False):
# eg.
Expand All @@ -113,7 +113,7 @@ def get_output_line(raw_line, srch_str):

fpath = os.path.realpath(fpath)
if debug:
print "processing [{}]".format(fpath)
print("processing [{}]".format(fpath))

tmpfpath = fpath+'.tmp'
with open(fpath, 'r') as f:
Expand All @@ -125,9 +125,9 @@ def get_output_line(raw_line, srch_str):
output_line = get_output_line(raw_line, srch_str)
ftmp.write(output_line)
if debug:
print "created {tmpfpath}".format(**locals())
print("created {tmpfpath}".format(**locals()))
shutil.move(tmpfpath, fpath) # move created tmp file to original file
print "updated {fpath}".format(**locals())
print("updated {fpath}".format(**locals()))

def set_version(seldon_core_version, pom_files, chart_yaml_files, values_yaml_file, core_jsonnet_file, debug=False):
# Normalize file paths
Expand Down Expand Up @@ -161,7 +161,7 @@ def main(argv):
if opts.debug:
pp(opts)
set_version(opts.seldon_core_version, POM_FILES, CHART_YAML_FILES, VALUES_YAML_FILE, CORE_JSONNET_FILE, opts.debug)
print "done"
print("done")

if __name__ == "__main__":
main(sys.argv)
Expand Down

0 comments on commit dcfc93d

Please sign in to comment.