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


Python SoCo.any_soco方法代码示例

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


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

示例1: _get_music_services_data_xml

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import any_soco [as 别名]
    def _get_music_services_data_xml(soco=None):
        """Fetch the music services data xml from a Sonos device.

        Args:
            soco (SoCo): a SoCo instance to query. If none is specified, a
            random device will be used.

        Returns:
            (str): a string containing the music services data xml

        """
        device = soco or SoCo.any_soco()
        log.debug("Fetching music services data from %s", device)
        available_services = device.musicServices.ListAvailableServices()
        descriptor_list_xml = available_services[
            'AvailableServiceDescriptorList']
        log.debug("Services descriptor list: %s", descriptor_list_xml)
        return descriptor_list_xml
开发者ID:intfrr,项目名称:SoCo,代码行数:20,代码来源:music_service.py

示例2: __init__

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import any_soco [as 别名]
    def __init__(self, endpoint, timeout, music_service):
        """ Initialise the instance

        Args:
             endpoint (str): The SOAP endpoint. A url.
             timeout (int): Timeout the connection after this number of
                 seconds
             music_service (MusicService): The MusicService object to which
                 this client belongs

        """

        self.endpoint = endpoint
        self.timeout = timeout
        self.music_service = music_service
        self.namespace = 'http://www.sonos.com/Services/1.1'

        self._cached_soap_header = None

        # Spotify uses gzip. Others may do so as well. Unzipping is handled
        # for us by the requests library. We set the user agent to a genuine
        # Sonos value since in some tests Google Play music seems to want
        # this. The firmware release number (after 'Sonos/') is obviously
        # fake, and higher than current values, in case Google only offers
        # certain services to certain firmware releases. ") Although we have
        # access to a real SONOS user agent string (one is returned, eg,
        # in the SERVER header of discovery packets and looks like this:
        # Linux UPnP/1.0 Sonos/29.5-91030 (ZPS3)) it is a bit too much
        # trouble here to access it, when this seems to work

        self.http_headers = {
            'Accept-Encoding': 'gzip, deflate',
            'User-agent': '"Linux UPnP/1.0 Sonos/99 (ZPS3)"'
        }
        self._device = SoCo.any_soco()
        self._device_id = self._device.systemProperties.GetString(
            [('VariableName', 'R_TrialZPSerial')])['StringValue']
开发者ID:intfrr,项目名称:SoCo,代码行数:39,代码来源:music_service.py


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