Merge lp:~roadmr/checkbox/1065703-audio-settings into lp:checkbox

Proposed by Daniel Manrique
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: 1834
Merged at revision: 1848
Proposed branch: lp:~roadmr/checkbox/1065703-audio-settings
Merge into: lp:checkbox
Diff against target: 50 lines (+12/-3)
2 files modified
debian/changelog (+2/-0)
scripts/audio_settings (+10/-3)
To merge this branch: bzr merge lp:~roadmr/checkbox/1065703-audio-settings
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Needs Resubmitting
Zygmunt Krynicki (community) Approve
Review via email: mp+135535@code.launchpad.net

Commit message

This code ensures that the audio settings storage file contains the required values. If they're not present, we barf with a useful error message.

Description of the change

This code ensures that the audio settings storage file contains the required values. If they're not present, we barf with a useful error message. Note that I'm not validating the format of the stored data itself. Also, I'm sure this could be done in a more elegant way but I chose this way because it can also easily be adapted to a backport of the fix for 0.14.x.

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Thanks, +1

review: Approve
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Attempt to merge into lp:checkbox failed due to conflicts:

text conflict in debian/changelog

Revision history for this message
Daniel Manrique (roadmr) wrote :

Fixed changelog and resubmitting :)

review: Needs Resubmitting
1834. By Daniel Manrique

merged from trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-12-12 09:48:07 +0000
3+++ debian/changelog 2012-12-12 14:39:21 +0000
4@@ -2,6 +2,8 @@
5
6 [ Daniel Manrique ]
7 * New version 0.15 for Raring Ringtail development.
8+ * Fail gracefully with a friendly and useful error message if audio settings
9+ file format is invalid. (LP: #1065703)
10 * Added environ key to poweroff and reboot jobs so they create logs in the
11 expected location (LP: #1085833)
12 * scripts/memory_compare: Fixed accumulator expression to give good results
13
14=== modified file 'scripts/audio_settings'
15--- scripts/audio_settings 2012-11-12 13:18:08 +0000
16+++ scripts/audio_settings 2012-12-12 14:39:21 +0000
17@@ -175,7 +175,16 @@
18 sys.exit(1)
19
20 for type in TYPES:
21- name = settings_file[settings_file.index("default_%s:" % type) + 1]
22+ #First try to get the three elements we need. If we fail to get any of them, it means
23+ #the file's format is incorrect, so we just abort.
24+ try:
25+ name = settings_file[settings_file.index("default_%s:" % type) + 1]
26+ muted = settings_file[settings_file.index("%s_muted:" % type) + 1]
27+ volume = settings_file[settings_file.index("%s_volume:" % type) + 1]
28+ except ValueError:
29+ print("Unable to restore settings because settings file is invalid")
30+ sys.exit(1)
31+
32 print(name)
33
34 try:
35@@ -187,7 +196,6 @@
36 if type == "sink":
37 move_sinks(name)
38
39- muted = settings_file[settings_file.index("%s_muted:" % type) + 1]
40 print(muted)
41
42 try:
43@@ -196,7 +204,6 @@
44 print("Failed to set mute for %s" % device)
45 sys.exit(1)
46
47- volume = settings_file[settings_file.index("%s_volume:" % type) + 1]
48 print(volume)
49
50 try:

Subscribers

People subscribed via source and target branches