本文整理汇总了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
示例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']