Merge lp:~pieq/checkbox/fix-1489817-audio-settings-volume-regexp into lp:checkbox
Status: | Merged |
---|---|
Approved by: | Po-Hsu Lin |
Approved revision: | 3976 |
Merged at revision: | 3976 |
Proposed branch: | lp:~pieq/checkbox/fix-1489817-audio-settings-volume-regexp |
Merge into: | lp:checkbox |
Diff against target: |
12 lines (+1/-1) 1 file modified
checkbox-support/checkbox_support/scripts/audio_settings.py (+1/-1) |
To merge this branch: | bzr merge lp:~pieq/checkbox/fix-1489817-audio-settings-volume-regexp |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Po-Hsu Lin | Approve | ||
Review via email: mp+269838@code.launchpad.net |
Description of the change
audio_settings script is used to store and restore values before and after audio tests.
To do this, it uses a few regular expressions. The one to find the volume value was wrong:
volume_regex = re.compile("Volume: (?:0|front-
Later in the code, we use group(1) to retrieve the value. However, as you can see above, group(1) will always be only one digit.
>>> vol100 = "Volume: 0: 100% 1: 100%"
>>> vol46 = "Volume: 0: 46% 1: 46%"
>>> vol4 = "Volume: 0: 4% 1: 4%"
>>> vol_regex = re.compile("Volume: (?:0|front-
>>> vol_regex.
'0'
>>> vol_regex.
'6'
By switching two characters in the previous regexp, everything works as expected:
volume_regex = re.compile("Volume: (?:0|front-
>>> vol_regex = re.compile("Volume: (?:0|front-
>>> vol_regex.
'46'
>>> vol_regex.
'100'
>>> vol_regex.
'4'
I tested the patch with `audio/
Looking good, thanks.