Merge ~jason-hobbs/layer-snap:fix-1843745 into ~stub/layer-snap:master

Proposed by Jason Hobbs
Status: Merged
Merged at revision: 136df3733af0fe732e92882872053dad6209b823
Proposed branch: ~jason-hobbs/layer-snap:fix-1843745
Merge into: ~stub/layer-snap:master
Diff against target: 14 lines (+1/-2)
1 file modified
lib/charms/layer/snap.py (+1/-2)
Reviewer Review Type Date Requested Status
Stuart Bishop Approve
Review via email: mp+372714@code.launchpad.net

Commit message

Don't use universal_newlines with subprocess.

This causes decode errors when the locale is ascii, which is
the default and is used in the juju hook context where no
locale is set.

LP: #1843745

Description of the change

We fixed a similar issue in the past; you can see the discussion for it here:

https://code.launchpad.net/~jason-hobbs/layer-snap/+git/layer-snap/+merge/366424

Here's what the output looks like with this fix:

2019-09-12 19:07:33 INFO juju-log Installing grafana from store
2019-09-12 19:08:04 DEBUG juju-log Installation successful cmd="['snap', 'install', '--channel=stable', 'grafana']" output="b'2019-09-12T19:07:54Z INFO Waiting for restart...\ngrafana 5.0.0 from Alvaro Ur\xc3\xada (aluria) installed\n'"

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Yup

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/charms/layer/snap.py b/lib/charms/layer/snap.py
2index 4929abe..88557aa 100644
3--- a/lib/charms/layer/snap.py
4+++ b/lib/charms/layer/snap.py
5@@ -313,8 +313,7 @@ def _install_store(snapname, **kw):
6 cmd.append(snapname)
7 hookenv.log('Installing {} from store'.format(snapname))
8 try:
9- out = subprocess.check_output(cmd, stderr=subprocess.STDOUT,
10- universal_newlines=True)
11+ out = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
12 hookenv.log('Installation successful cmd="{}" output="{}"'
13 .format(cmd, out),
14 level=hookenv.DEBUG)

Subscribers

People subscribed via source and target branches

to all changes: