def __init__(self, settings, args): self.settings = settings self.connected = False try: params = dict(arg.split("=") for arg in args.split("&")) except Exception: params = {} if params == {}: # if there's a bridge IP, try to talk to it. if self.settings.bridge_ip not in ["-", "", None]: result = bridge.user_exists( self.settings.bridge_ip, self.settings.bridge_user ) if result: self.connected = True self.update_controllers() elif params['action'] == "discover": ui.discover_hue_bridge(self) self.update_controllers() elif params['action'] == "reset_settings": os.unlink(os.path.join(__addondir__, "settings.xml")) elif params['action'] == "setup_theater_lights": xbmc.executebuiltin('NotifyAll({}, {})'.format( __addon__.getAddonInfo('id'), 'start_setup_theater_lights')) elif params['action'] == "setup_theater_subgroup": xbmc.executebuiltin('NotifyAll({}, {})'.format( __addon__.getAddonInfo('id'), 'start_setup_theater_subgroup')) elif params['action'] == "setup_ambilight_lights": xbmc.executebuiltin('NotifyAll({}, {})'.format( __addon__.getAddonInfo('id'), 'start_setup_ambilight_lights')) elif params['action'] == "setup_static_lights": xbmc.executebuiltin('NotifyAll({}, {})'.format( __addon__.getAddonInfo('id'), 'start_setup_static_lights')) else: # not yet implemented pass if self.connected: if self.settings.misc_initialflash: self.ambilight_controller.flash_lights() self.theater_controller.flash_lights() self.static_controller.flash_lights()
def test_user_exists_negative(m): m.register_uri('GET', 'http://127.0.0.1/api/fake/config', json={'whitelist': []}) assert not bridge.user_exists(BRIDGE_IP, USERNAME, notify=False)