Merge lp:~roadmr/checkbox/audio-test-fixes into lp:checkbox

Proposed by Daniel Manrique
Status: Merged
Approved by: Marc Tardif
Approved revision: 1791
Merged at revision: 1790
Proposed branch: lp:~roadmr/checkbox/audio-test-fixes
Merge into: lp:checkbox
Diff against target: 81 lines (+22/-8)
2 files modified
debian/changelog (+3/-0)
scripts/audio_test (+19/-8)
To merge this branch: bzr merge lp:~roadmr/checkbox/audio-test-fixes
Reviewer Review Type Date Requested Status
Marc Tardif (community) Approve
Daniel Manrique (community) Needs Resubmitting
Review via email: mp+130637@code.launchpad.net

Commit message

Added retrying with a pause when invoking pacmd, to guard against uninitialized pulseaudio

Description of the change

Added retrying with a pause when invoking pacmd, to guard against uninitialized pulseaudio.

To post a comment you must log in.
Revision history for this message
Marc Tardif (cr3) wrote :

I'm not sure I understand when check_output might raise an AttributeError exception. First, I'd make sure this is even possible. Second, if it is, I suspect it might have to be handled differently than the CallProcessError exception. For example, you might not want to continue looping when an AttributeError exception is raised because it might not make sense.

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

Thanks for spotting that, since check_output is the only method called in the block, and that does not return AttributeError under any circumstances, I just removed it.

review: Needs Resubmitting
Revision history for this message
Marc Tardif (cr3) wrote :

Sweet! I'll just approve and let tarmac complain about the merge conflict, thanks!

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

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Marc Tardif (cr3) wrote :

Oh boy, now I get to review a second time!

review: Approve

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-10-22 14:38:54 +0000
3+++ debian/changelog 2012-10-22 20:18:18 +0000
4@@ -1,5 +1,6 @@
5 checkbox (0.14.10) quantal; urgency=low
6
7+ [ Jeff Lane ]
8 * Increased version number after final Ubuntu Quantal release.
9
10 [Brendan Donegan]
11@@ -27,6 +28,8 @@
12 filling the screen with dots. (LP: #926104)
13 * Increased version number after final Ubuntu Quantal release.
14 * Added environment resource to whitelists (LP: #1067038)
15+ * Added retrying pactl commands in case audio layer is not up yet
16+ (LP: #1065908)
17
18 [Marc Tardif]
19 * plugins/environment_info.py: Enabling environment to take precedence
20
21=== modified file 'scripts/audio_test'
22--- scripts/audio_test 2012-08-30 15:34:42 +0000
23+++ scripts/audio_test 2012-10-22 20:18:18 +0000
24@@ -8,6 +8,7 @@
25 import re
26 import sys
27 import subprocess
28+import time
29 #Trick to prevent gst from hijacking argv parsing
30 argv = sys.argv
31 sys.argv = []
32@@ -205,10 +206,18 @@
33 return valid_elements[0]
34
35 def _pactl_output(self, command):
36- try:
37- return subprocess.check_output(command, universal_newlines=True)
38- except (subprocess.CalledProcessError, AttributeError):
39- return False
40+ #This method mainly calls pactl (hence the name). Since pactl may
41+ #return a failure if the audio layer is not yet initialized, we will
42+ #try running a few times in case of failure. All our invocations of
43+ #pactl should be "idempotent" so repeating them should not have
44+ #any bad effects.
45+ for attempt in range(0, 3):
46+ try:
47+ return subprocess.check_output(command,
48+ universal_newlines=True)
49+ except (subprocess.CalledProcessError):
50+ time.sleep(5)
51+ return False
52
53
54 class FileDumper(object):
55@@ -567,8 +576,8 @@
56 return_value = 1
57 #Is the microphone broken?
58 if len(set(analyzer.spectrum)) <= 1:
59- logging.info("WARNING: Microphone seems broken, didn't even record ambient"
60- " noise")
61+ logging.info("WARNING: Microphone seems broken, didn't even "
62+ "record ambient noise")
63
64 #Write some files to disk for later analysis
65 if args.audio:
66@@ -580,12 +589,14 @@
67
68 if args.spectrum:
69 if args.verbose:
70- logging.info("Saving spectrum data for plotting as %s" % args.spectrum)
71+ logging.info("Saving spectrum data for plotting as %s" %
72+ args.spectrum)
73 if not FileDumper().write_to_file(args.spectrum,
74 ["%s,%s" % t for t in
75 zip(analyzer.frequencies,
76 analyzer.spectrum)]):
77- logging.error("Couldn't save spectrum data for plotting", file=sys.stderr)
78+ logging.error("Couldn't save spectrum data for plotting",
79+ file=sys.stderr)
80
81 return return_value
82

Subscribers

People subscribed via source and target branches