Skip to content

Commit

Permalink
Use native strs for build failure error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
avirshup committed Feb 22, 2018
1 parent ca84700 commit 8086093
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 5 additions & 1 deletion codeship-steps.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
- name: clean-build
service: avirshup/docker-make
command: sh -c "rm -f /opt/distfiles/*"

- name: build-pkg
service: avirshup/docker-make
command: sh -c 'cp -v /opt/DockerMake/dist/DockerMake-*.tar.gz /opt/distfiles/'
Expand All @@ -9,7 +13,7 @@
- testenv-python3.5
- testenv-python3.6
steps:
- command: sh -c "pip install /opt/distfiles/DockerMake-*.tar.gz && py.test"
- command: sh -c "pip install /opt/distfiles/DockerMake-*.tar.gz && py.test -v"

- name: deploy-dockerhub
type: push
Expand Down
13 changes: 8 additions & 5 deletions dockermake/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from io import StringIO
import io
import pprint
from termcolor import cprint
from future.utils import PY2

class UserException(Exception):
"""
Expand Down Expand Up @@ -84,12 +85,14 @@ class BuildError(Exception):
def __init__(self, dockerfile, item, build_args):
with open('dockerfile.fail', 'w') as dff:
print(dockerfile, file=dff)
with StringIO() as stream:

buffer_class = io.BytesIO if PY2 else io.StringIO
with buffer_class() as stream:
cprint('Docker build failure', 'red', attrs=['bold'], file=stream)
print(u'\n -------- Docker daemon output --------', file=stream)
print('\n -------- Docker daemon output --------', file=stream)
pprint.pprint(item, stream, indent=4)
print(u' -------- Arguments to client.build --------', file=stream)
print(' -------- Arguments to client.build --------', file=stream)
pprint.pprint(build_args, stream, indent=4)
print(u'This dockerfile was written to dockerfile.fail', file=stream)
print('This dockerfile was written to dockerfile.fail', file=stream)
stream.seek(0)
super(BuildError, self).__init__(stream.read())

0 comments on commit 8086093

Please sign in to comment.