当前位置: 首页>>代码示例>>Python>>正文


Python phue.PhueRegistrationException方法代码示例

本文整理汇总了Python中phue.PhueRegistrationException方法的典型用法代码示例。如果您正苦于以下问题:Python phue.PhueRegistrationException方法的具体用法?Python phue.PhueRegistrationException怎么用?Python phue.PhueRegistrationException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phue的用法示例。


在下文中一共展示了phue.PhueRegistrationException方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: try_bridge_connection

# 需要导入模块: import phue [as 别名]
# 或者: from phue import PhueRegistrationException [as 别名]
def try_bridge_connection(self, cb):
        import phue

        while True:
            try:
                bridge = phue.Bridge(ip=self.selected_bridge)
            except phue.PhueRegistrationException:
                time.sleep(1)
            except Exception:
                import traceback
                traceback.print_exc()
                break
            else:
                self.bridge = bridge
                break

        GLib.idle_add(cb) 
开发者ID:craigcabrey,项目名称:luminance,代码行数:19,代码来源:setup.py

示例2: _register_with_bridge

# 需要导入模块: import phue [as 别名]
# 或者: from phue import PhueRegistrationException [as 别名]
def _register_with_bridge(self):
        """
        Helper for connecting to the bridge. If we don't
        have a valid username for the bridge (ip) we are trying
        to use, this will cause one to be generated.
        """
        self.speak_dialog('connect.to.bridge')
        i = 0
        while i < 30:
            sleep(1)
            try:
                self.bridge = Bridge(self.ip)
            except PhueRegistrationException:
                continue
            else:
                break
        if not self.connected:
            self.speak_dialog('failed.to.register')
        else:
            self.speak_dialog('successfully.registered') 
开发者ID:ChristopherRogers1991,项目名称:mycroft-hue,代码行数:22,代码来源:__init__.py

示例3: test_change_light_color_no_bridge

# 需要导入模块: import phue [as 别名]
# 或者: from phue import PhueRegistrationException [as 别名]
def test_change_light_color_no_bridge(self, mockedPhue):
        mockedPhue.PhueRegistrationException = phue.PhueRegistrationException
        bridge = mock.MagicMock()
        bridge.connect.side_effect = mockedPhue.PhueRegistrationException(0, "error")
        mockedPhue.Bridge.return_value = bridge

        action.ChangeLightColor(self._say, "philips-hue", "Lounge Lamp", "0077be").run()

        self.assertEqual(self._say_text,
                         "No bridge registered, press button on bridge and try again") 
开发者ID:google,项目名称:aiyprojects-raspbian,代码行数:12,代码来源:test_change_light_color.py

示例4: find_bridge

# 需要导入模块: import phue [as 别名]
# 或者: from phue import PhueRegistrationException [as 别名]
def find_bridge(self):
        try:
            bridge = phue.Bridge(self.bridge_address)
            bridge.connect()
            return bridge
        except phue.PhueRegistrationException:
            logging.info("hue: No bridge registered, press button on bridge and try again")
            self.say(_("No bridge registered, press button on bridge and try again"))


# Power: Shutdown or reboot the pi
# ================================
# Shuts down the pi or reboots with a response
# 
开发者ID:google,项目名称:aiyprojects-raspbian,代码行数:16,代码来源:action.py

示例5: connect

# 需要导入模块: import phue [as 别名]
# 或者: from phue import PhueRegistrationException [as 别名]
def connect(self):
        """ Connect to Phillips Hue Hub """
        # pylint: disable=broad-except
        # get hub settings
        hub = self.nodes['hub']
        ip_addr = '{}.{}.{}.{}'.format(
            hub.get_driver('GV1')[0], hub.get_driver('GV2')[0],
            hub.get_driver('GV3')[0], hub.get_driver('GV4')[0])

        # try to authenticate with the hub
        try:
            self.hub = phue.Bridge(
                ip_addr, config_file_path=os.path.join(os.getcwd(), 'bridges'))
        except phue.PhueRegistrationException:
            self.poly.send_error('IP Address OK. Node Server not registered.')
            return False
        except Exception:
            self.poly.send_error('Cannot find hub at {}'.format(ip_addr))
            return False  # bad ip Addressse:
        else:
            # ensure hub is connectable
            api = self._get_api()

            if api:
                hub.set_driver('GV5', 1)
                hub.report_driver()
                return True
            else:
                self.hub = None
                return False 
开发者ID:UniversalDevicesInc,项目名称:Polyglot,代码行数:32,代码来源:hue.py

示例6: _connect_to_bridge

# 需要导入模块: import phue [as 别名]
# 或者: from phue import PhueRegistrationException [as 别名]
def _connect_to_bridge(self, acknowledge_successful_connection=False):
        """
        Calls _attempt_connection, handling various exceptions
        by either alerting the user to issues with the config/setup,
        or registering the application with the bridge.

        Parameters
        ----------
        acknowledge_successful_connection : bool
            Speak when a successful connection is established.

        Returns
        -------
        bool
            True if a connection is established.

        """
        try:
            self._attempt_connection()
        except DeviceNotFoundException:
            self.speak_dialog('bridge.not.found')
            return False
        except ConnectionError:
            self.speak_dialog('failed.to.connect')
            if self.user_supplied_ip:
                self.speak_dialog('ip.in.config')
            return False
        except socket.error as e:
            if 'No route to host' in e.args:
                self.speak_dialog('no.route')
            else:
                self.speak_dialog('failed.to.connect')
            return False
        except UnauthorizedUserException:
            if self.user_supplied_username:
                self.speak_dialog('invalid.user')
                return False
            else:
                self._register_with_bridge()
        except PhueRegistrationException:
            self._register_with_bridge()

        if not self.connected:
            return False

        if acknowledge_successful_connection:
            self.speak_dialog('successfully.connected')

        self._update_bridge_data()

        return True 
开发者ID:ChristopherRogers1991,项目名称:mycroft-hue,代码行数:53,代码来源:__init__.py


注:本文中的phue.PhueRegistrationException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。