From 2eed133ca3b13481ffaf099a93d5c7483be30f7b Mon Sep 17 00:00:00 2001 From: Daigo Tanaka Date: Thu, 6 Aug 2020 03:46:21 -0700 Subject: [PATCH] Mac OS fix (#30) * fix Mac OS bugs * fix tutorial paths * fix sed issue on mac * bump version to 0.2.0b1 --- HISTORY.md | 6 ++++++ handoff/config.py | 2 +- handoff/services/container/docker/impl.py | 12 ++++++++---- .../test_projects/scripts/aws_get_started/06_fargate | 2 +- handoff/test_projects/scripts/funcs | 8 ++++---- setup.py | 2 +- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index a9a04d5..5f90640 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,11 @@ ## History +### 0.2.0b1 (2020-08-05) + +- Mac OS: fix a bug in parsing Docker build JSON log +- Mac OS: fix sed -u issue +- Fix typos in tutorial + ### 0.2.0b0 (2020-08-05) - Beta diff --git a/handoff/config.py b/handoff/config.py index 3b485da..78de732 100644 --- a/handoff/config.py +++ b/handoff/config.py @@ -1,4 +1,4 @@ -VERSION = "0.2.0b0" +VERSION = "0.2.0b1" import os, re from handoff import utils diff --git a/handoff/services/container/docker/impl.py b/handoff/services/container/docker/impl.py index a82377c..a558b29 100644 --- a/handoff/services/container/docker/impl.py +++ b/handoff/services/container/docker/impl.py @@ -81,9 +81,13 @@ def build(project_dir, new_version=None, docker_file=None, nocache=False): for line in cli.build(path=build_dir, tag=image_name + ":" + new_version, nocache=nocache): - msg = json.loads(line.decode("utf-8")) - if msg.get("stream") and msg["stream"] != "\n": - logger.info(msg["stream"]) + for subline in line.decode("utf-8").split("\n"): + try: + msg = json.loads(subline) + except json.decoder.JSONDecodeError: + continue + if msg.get("stream") and msg["stream"] != "\n": + logger.info(msg["stream"]) def run(version=None, extra_env=dict()): @@ -138,7 +142,7 @@ def push(username, password, registry, version=None): version, stream=True): try: msg = json.loads(line.decode("utf-8")) - except Exception: + except json.decoder.JSONDecodeError: continue total = 0 current = 0 diff --git a/handoff/test_projects/scripts/aws_get_started/06_fargate b/handoff/test_projects/scripts/aws_get_started/06_fargate index db4ef26..b85ce0e 100755 --- a/handoff/test_projects/scripts/aws_get_started/06_fargate +++ b/handoff/test_projects/scripts/aws_get_started/06_fargate @@ -110,7 +110,7 @@ At the bottom of the page, you see: | Name | Container Runtime ID | Status | Image | ..... | | :---------------- | :------------------- | :----------- | :---- | :---- | -| singer_excha... | 1371.... | PROVISIONING | xxxxx | ..... | +| singer_excha... | 1371.... | PROVISIONING | xxxxx | ..... | Expand the section by clicking on a dark side-way trible ">" by the Task name. diff --git a/handoff/test_projects/scripts/funcs b/handoff/test_projects/scripts/funcs index f2d0850..4e59c84 100755 --- a/handoff/test_projects/scripts/funcs +++ b/handoff/test_projects/scripts/funcs @@ -39,7 +39,8 @@ Run() { if [[ -z $2 ]]; then STYLE=$DIM; else STYLE=$2; fi if [[ ! -z $3 ]];then h=$3; else if [[ ! -z $HEADTAIL_LIMIT ]]; then h=$HEADTAIL_LIMIT; else h=0; fi; fi if [[ ! $MODE = "auto" ]]; then echo -e $STYLE$QUOTE; else echo $BEGINQUOTE; echo; fi -if [[ $h -lt 1 ]]; then eval "$1"; else eval "$1" | (sed -u ${h}q; t=`tail -n $h`; if [[ `echo "$t" | wc -l` -gt 1 ]]; then echo .; echo .; echo .; echo "$t"; fi); fi +if [[ $h -lt 1 ]]; then eval "$1"; else eval "$1" | (head -n ${h}; t=`tail -n $h`; if [[ `echo "$t" | wc -l` -gt 1 ]]; then echo .; echo .; echo .; echo "$t"; fi); fi +# if [[ $h -lt 1 ]]; then eval "$1"; else eval "$1" | (sed -u ${h}q; t=`tail -n $h`; if [[ `echo "$t" | wc -l` -gt 1 ]]; then echo .; echo .; echo .; echo "$t"; fi); fi if [[ ! $MODE = "auto" ]]; then echo -e $QUOTE$RESET; else echo $QUOTE; fi } @@ -90,7 +91,6 @@ fi Choose() { echo $1 IFS=$'\n' read -r -d '' -a OPTIONS < <( eval $1 ) -# IFS=$'\n' read -r -d '' -a OPTIONS < <( ls $PROJECT_DIR/scripts | grep -v funcs && printf '\0' ) i=1 for s in ${OPTIONS[@]}; do echo "- [$i] $s"; i=$((i+1)); done @@ -118,7 +118,7 @@ if [[ ! $REPLY =~ ^[Nn]$ ]] then echo "OK!" echo - $PROJECT_DIR/scripts/03_set_up_aws_account + scripts/aws_get_started/03_set_up_aws_account exit 0 fi fi @@ -169,7 +169,7 @@ if [[ $REPLY =~ ^[Nn]$ ]] then echo "OK!" echo "Remember that you can continue by" - echo -e $GREEN $PROJECT_DIR/begin$RESET + echo -e $GREEN ./projects/start$RESET echo echo "bye!" exit 0 diff --git a/setup.py b/setup.py index 8f53402..e56dbe9 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from setuptools import setup -VERSION="0.2.0b0" +VERSION="0.2.0b1" with open("README.md", "r") as fh: long_description = fh.read()