Merge ~jocave/checkbox-support:print-checkbox-conf into checkbox-support:master

Proposed by Jonathan Cave
Status: Merged
Approved by: Jonathan Cave
Approved revision: 0d6c301ef36c1a8cee6a467cab373f18abb02f62
Merged at revision: a2b0f83b73bbab67974192bba16151884d0fc1bf
Proposed branch: ~jocave/checkbox-support:print-checkbox-conf
Merge into: checkbox-support:master
Diff against target: 21 lines (+10/-0)
1 file modified
checkbox_support/snap_utils/config.py (+10/-0)
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+336326@code.launchpad.net

Description of the change

Add a function to print the values of the environment section of the checkbox.conf stored in SNAP_DATA directory.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

Is it worth ensuring the path exists? Otherwise, +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 53e71fc..c33bafc 100644
3--- a/checkbox_support/snap_utils/config.py
4+++ b/checkbox_support/snap_utils/config.py
5@@ -117,6 +117,16 @@ def write_checkbox_conf(configuration):
6 config.write(stream)
7
8
9+def print_checkbox_conf():
10+ """Print the current checkbox.conf in $SNAP_DATA."""
11+ checkbox_conf_path = os.path.expandvars("$SNAP_DATA/checkbox.conf")
12+ config = configparser.ConfigParser()
13+ config.optionxform = str
14+ config.read(checkbox_conf_path)
15+ for key in config['environment']:
16+ print('{}={}'.format(key, config['environment'][key]))
17+
18+
19 def refresh_configuration():
20 """
21 Read config_vars, write the ones missing in snapd

Subscribers

People subscribed via source and target branches