Merge ~zhhuabj/layer-snap:lp1847574 into ~stub/layer-snap:master

Proposed by Hua Zhang
Status: Merged
Merged at revision: a9d507c4925e3daf9d9d84eba1618f783439ea4b
Proposed branch: ~zhhuabj/layer-snap:lp1847574
Merge into: ~stub/layer-snap:master
Diff against target: 20 lines (+2/-2)
1 file modified
lib/charms/layer/snap.py (+2/-2)
Reviewer Review Type Date Requested Status
Stuart Bishop Approve
Review via email: mp+374077@code.launchpad.net

Commit message

python3.5 subprocess.check_output() doesn't support encoding argument according to the doc [1], so the command 'juju deploy cs:graylog-39 --config channel=3/stable --series xenial' doesn't work, this change is used to fix it.

[1] https://docs.python.org/3.5/library/subprocess.html

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

I'd like this to be .decode('utf-8', errors='replace') while we are here, to avoid crashing if the output is not valid UTF-8.

review: Needs Fixing
Revision history for this message
Stuart Bishop (stub) wrote :

Easiest if I make the change while merging this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/charms/layer/snap.py b/lib/charms/layer/snap.py
index 88557aa..162667c 100644
--- a/lib/charms/layer/snap.py
+++ b/lib/charms/layer/snap.py
@@ -253,7 +253,7 @@ def get_installed_version(snapname):
253 'Cannot get {} snap installed version because it is not installed'253 'Cannot get {} snap installed version because it is not installed'
254 .format(snapname), hookenv.WARNING)254 .format(snapname), hookenv.WARNING)
255 return255 return
256 return subprocess.check_output(cmd, encoding='utf-8').partition(256 return subprocess.check_output(cmd).decode('utf-8').partition(
257 'installed:')[-1].split()[0]257 'installed:')[-1].split()[0]
258258
259259
@@ -268,7 +268,7 @@ def get_installed_channel(snapname):
268 'Cannot get snap tracking (channel) because it is not installed'268 'Cannot get snap tracking (channel) because it is not installed'
269 .format(snapname), hookenv.WARNING)269 .format(snapname), hookenv.WARNING)
270 return270 return
271 return subprocess.check_output(cmd, encoding='utf-8').partition(271 return subprocess.check_output(cmd).decode('utf-8').partition(
272 'tracking:')[-1].split()[0]272 'tracking:')[-1].split()[0]
273273
274274

Subscribers

People subscribed via source and target branches

to all changes: