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 (community) 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
diff --git a/checkbox_support/snap_utils/config.py b/checkbox_support/snap_utils/config.py
index aaa7499..53e71fc 100644
--- a/checkbox_support/snap_utils/config.py
+++ b/checkbox_support/snap_utils/config.py
@@ -63,11 +63,8 @@ def get_snapctl_config(keys):
63 """Query snapctl for given keys."""63 """Query snapctl for given keys."""
64 if len(keys) == 0:64 if len(keys) == 0:
65 return dict()65 return dict()
66 out = subprocess.check_output(['snapctl', 'get'] + keys).decode(66 out = subprocess.check_output(['snapctl', 'get', '-d'] + keys).decode(
67 sys.stdout.encoding)67 sys.stdout.encoding)
68 if len(keys) == 1:
69 # snapctl returns bare string with a value when quering for one only
70 return {keys[0]: out.strip()}
71 return json.loads(out)68 return json.loads(out)
7269
7370

Subscribers

People subscribed via source and target branches