Merge ~jocave/checkbox-support:extra-snapctl-support into checkbox-support:master

Proposed by Jonathan Cave
Status: Merged
Approved by: Jonathan Cave
Approved revision: bd913c909cc6f679e18f52a2224473b5e9846271
Merged at revision: e8cbedbc9b8510569554a6de4400d83206e30cd3
Proposed branch: ~jocave/checkbox-support:extra-snapctl-support
Merge into: checkbox-support:master
Diff against target: 15 lines (+1/-4)
1 file modified
checkbox_support/snap_utils/config.py (+1/-4)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Jonathan Cave (community) Needs Resubmitting
Maciej Kisielewski Needs Fixing
Review via email: mp+332017@code.launchpad.net

Description of the change

Found that snapctl can take a "-d" flag thereby ensuring a json document is always returned and avoiding the workaround in this code.

Added a snapctl set function.

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Looks good. Thanks for the set function.

review: Approve
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

Deduplication needed.

review: Needs Fixing
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

Oh, and that additional newline landed here:
https://git.launchpad.net/checkbox-support/commit/?id=d0f3fad4f46adf696628a12522346173436a49a9

so this branch needs a rebase

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :
review: Needs Fixing
Revision history for this message
Jonathan Cave (jocave) wrote :

Rebased the branch and dropped all but the changes requested by Sylvain.

review: Needs Resubmitting
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Thank you, +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/checkbox_support/snap_utils/config.py b/checkbox_support/snap_utils/config.py
2index aaa7499..53e71fc 100644
3--- a/checkbox_support/snap_utils/config.py
4+++ b/checkbox_support/snap_utils/config.py
5@@ -63,11 +63,8 @@ def get_snapctl_config(keys):
6 """Query snapctl for given keys."""
7 if len(keys) == 0:
8 return dict()
9- out = subprocess.check_output(['snapctl', 'get'] + keys).decode(
10+ out = subprocess.check_output(['snapctl', 'get', '-d'] + keys).decode(
11 sys.stdout.encoding)
12- if len(keys) == 1:
13- # snapctl returns bare string with a value when quering for one only
14- return {keys[0]: out.strip()}
15 return json.loads(out)
16
17

Subscribers

People subscribed via source and target branches