Merge lp://staging/~2xyo/indicator-brightness/trunk into lp://staging/indicator-brightness

Proposed by 2xyo
Status: Merged
Approved by: Jan Simon
Approved revision: 3
Merged at revision: 3
Proposed branch: lp://staging/~2xyo/indicator-brightness/trunk
Merge into: lp://staging/indicator-brightness
Diff against target: 20 lines (+7/-3)
1 file modified
indicator-brightness.py (+7/-3)
To merge this branch: bzr merge lp://staging/~2xyo/indicator-brightness/trunk
Reviewer Review Type Date Requested Status
Jan Simon Approve
Review via email: mp+126967@code.staging.launchpad.net

Description of the change

Summary :
When "/usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-brightness" reports the error message "WARNING **: failed to find any devices" a exception is thrown in get_curr_brightness() :

$ ./indicator-brightness.py

** (gsd-backlight-helper:7925): WARNING **: failed to find any devices

** (gsd-backlight-helper:7928): WARNING **: failed to find any devices
Traceback (most recent call last):
  File "./indicator-brightness.py", line 93, in <module>
    create_menu(ind)
  File "./indicator-brightness.py", line 60, in create_menu
    curr_brightness = get_curr_brightness()
  File "./indicator-brightness.py", line 38, in get_curr_brightness
    curr_brightness = int(p.communicate()[0])
ValueError: invalid literal for int() with base 10: '

Proposed fix :
Add a try/except bloc to handle warning message of "/usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-brightness"

Implementation details :
def get_curr_brightness():
  c = 0
  try:
    p = subprocess.Popen(['pkexec','/usr/lib/gnome-settings-daemon/gsd-backlight-helper','--get-brightness'], stdout=subprocess.PIPE)
    curr_brightness = int(p.communicate()[0])
    c = closest(curr_brightness, brightness_settings)
  except:
    c = 0
  return brightness_settings.index(c)

Tests :
./indicator-brightness.py

Lint :
The change does not add errors to pychecker

To post a comment you must log in.
Revision history for this message
Jan Simon (jan-simon) wrote :

Thanks for the commit!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: