~alphapapa/pithos/888778

« back to all changes in this revision

Viewing changes to pithos/plugins/mediakeys.py

  • Committer: Adam Porter
  • Date: 2011-12-25 15:01:53 UTC
  • Revision ID: adam@alphapapa.net-20111225150153-5suhhy91ccsszkv0
Added exception handling.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
        except:
53
53
            return False
54
54
        
55
 
        keybinder.bind('XF86AudioPlay', self.window.playpause, None)
56
 
        keybinder.bind('XF86AudioStop', self.window.user_pause, None)
57
 
        keybinder.bind('XF86AudioNext', self.window.next_song, None)
58
 
        keybinder.bind('XF86AudioPrev', self.window.toggle_window, None)
 
55
        try:
 
56
            keybinder.bind('XF86AudioPlay', self.window.playpause, None)
 
57
            keybinder.bind('XF86AudioStop', self.window.user_pause, None)
 
58
            keybinder.bind('XF86AudioNext', self.window.next_song, None)
 
59
            keybinder.bind('XF86AudioPrev', self.window.toggle_window, None)
59
60
        
60
 
        logging.info("Bound media keys with keybinder")
61
 
        self.method = 'keybinder'
62
 
        return True
 
61
            logging.info("Bound media keys with keybinder")
 
62
            self.method = 'keybinder'
 
63
            return True
 
64
        except Exception, message:
 
65
            logging.error("Failed to bind media keys with keybinder: %s: %s" % (Exception, message))
 
66
            return False
63
67
        
64
68
    def on_enable(self):
65
69
        self.bind_dbus() or self.bind_keybinder() or logging.error("Could not bind media keys")