コード例 #1
0
ファイル: __init__.py プロジェクト: nikron/bridge
    def transform_action_to_message(self, uuid, action, *args, **kwargs):
        """
        Perform an action on UUID asset.
        An action must return a BridgeMessge, so this gets that and returns it.

        :param uuid: The asset to perform the action on.
        :type uuid: uuid

        :param action: The action to perform.
        :type action: str

        :param *args: The arguments for the action.
        :type args: list

        :param kwargs: The keyword arguments for the action.
        :type kwargs: dict

        :return: :class:`BridgeMessage` if successful or None if unsuccessful
        :rtype: :class:`BridgeMessage`
        """
        asset = self.assets.get(uuid)

        if asset is not None:
            return perform_action(asset, action, *args, **kwargs)
        else:
            logging.error("{0} does not exist in this model, can not perform action {1}.".format(uuid, action))
            return None
コード例 #2
0
ファイル: insteonidiomtest.py プロジェクト: nikron/bridge
    def test_create_onoffasset(self):
        asset = self.idiom.create_asset('Home Appliance', self.fake_real_id, 'ApplianceLinc V2')
        ret = perform_action(asset, 'turn_on')

        self.assertEquals('test_service', ret.to)
コード例 #3
0
ファイル: assettest.py プロジェクト: nikron/bridge
 def test_off(self):
     ret = perform_action(self.asset, 'turn_off')
     self.assertEquals(ret.method, 'turn_off')
コード例 #4
0
ファイル: actiontest.py プロジェクト: nikron/bridge
 def test_action(self):
     perform_action(self.inner, 'floop')
     self.assertTrue(self.inner.x)