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
1diff --git a/lib/charms/layer/snap.py b/lib/charms/layer/snap.py
2index 88557aa..162667c 100644
3--- a/lib/charms/layer/snap.py
4+++ b/lib/charms/layer/snap.py
5@@ -253,7 +253,7 @@ def get_installed_version(snapname):
6 'Cannot get {} snap installed version because it is not installed'
7 .format(snapname), hookenv.WARNING)
8 return
9- return subprocess.check_output(cmd, encoding='utf-8').partition(
10+ return subprocess.check_output(cmd).decode('utf-8').partition(
11 'installed:')[-1].split()[0]
12
13
14@@ -268,7 +268,7 @@ def get_installed_channel(snapname):
15 'Cannot get snap tracking (channel) because it is not installed'
16 .format(snapname), hookenv.WARNING)
17 return
18- return subprocess.check_output(cmd, encoding='utf-8').partition(
19+ return subprocess.check_output(cmd).decode('utf-8').partition(
20 'tracking:')[-1].split()[0]
21
22

Subscribers

People subscribed via source and target branches

to all changes: