本文整理汇总了Python中settings.Settings.getIPAddress方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.getIPAddress方法的具体用法?Python Settings.getIPAddress怎么用?Python Settings.getIPAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings.Settings
的用法示例。
在下文中一共展示了Settings.getIPAddress方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getIPAddress [as 别名]
def check(self):
if Settings.autoPauseSonos() and not Settings.linkAudioWithSonos():
try:
# Check to see if something has started playing
if xbmc.Player().isPlaying():
# If this is a change in play state since the last time we checked
if self.xbmcPlayState is False:
log("SonosAutoPause: Automatically pausing Sonos")
self.xbmcPlayState = True
# Pause the sonos if it is playing
if self._isSonosPlaying():
self.sonosDevice.pause()
self.autoStopped = True
self.resumeCountdown = Settings.autoResumeSonos()
else:
self.xbmcPlayState = False
if Settings.autoResumeSonos() > 0 and self.autoStopped:
if self.resumeCountdown > 0:
self.resumeCountdown = self.resumeCountdown - 1
else:
log("SonosAutoPause: Automatically resuming Sonos")
self.sonosDevice.play()
self.autoStopped = False
self.resumeCountdown = Settings.autoResumeSonos()
except:
# If we fail to stop the speaker playing, it may be because
# there is a network problem or the speaker is powered down
# So we just continue after logging the error
log("SonosAutoPause: Error from speaker %s" % Settings.getIPAddress())
log("SonosAutoPause: %s" % traceback.format_exc())
示例2: createSonosDevice
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getIPAddress [as 别名]
def createSonosDevice(ipAddress=None):
# Set up the logging before using the Sonos Device
SocoLogging.enable()
sonosDevice = None
if ipAddress is None:
ipAddress = Settings.getIPAddress()
if ipAddress != "0.0.0.0":
sonosDevice = Sonos(ipAddress)
log("Sonos: IP Address = %s" % ipAddress)
return sonosDevice
示例3: _switchToLineIn
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getIPAddress [as 别名]
def _switchToLineIn(self):
# Check if we need to ensure the Sonos system is using the line-in
try:
# Not all speakers support line-in - so catch exception
self.sonosDevice.switch_to_line_in()
# Once switch to line in, some systems require that a play command is sent
self.sonosDevice.play()
except:
log("SonosService: Failed to switch to Line-In for speaker %s" % Settings.getIPAddress())
log("SonosService: %s" % traceback.format_exc())
示例4: createSonosDevice
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getIPAddress [as 别名]
def createSonosDevice(ipAddress=None):
# Need to make sure that we override the SoCo class with the Sonos one
config.SOCO_CLASS = Sonos
# Set up the logging before using the Sonos Device
SocoLogging.enable()
sonosDevice = None
if ipAddress is None:
ipAddress = Settings.getIPAddress()
if ipAddress != "0.0.0.0":
sonosDevice = Sonos(ipAddress)
log("Sonos: IP Address = %s" % ipAddress)
return sonosDevice
示例5: log
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getIPAddress [as 别名]
# Wait a second or so before updating
xbmc.sleep(Settings.getRefreshInterval())
stopScreensaver = stopScreensaver - Settings.getRefreshInterval()
if stopScreensaver < 0:
# A bit of a hack, but we need Kodi to think a user is "doing things" so
# that it does not start the screensaver, so we just send the message
# to open the Context menu - which in our case will do nothing
# but it does make Kodi think the user has done something
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Input.ContextMenu", "id": 1}')
stopScreensaver = 40000
except:
# Failed to connect to the Sonos Speaker
log("Sonos: Exception Details: %s" % traceback.format_exc(), xbmc.LOGERROR)
xbmcgui.Dialog().ok(__addon__.getLocalizedString(32001), (__addon__.getLocalizedString(32066) % Settings.getIPAddress()))
# Need to check to see if we can stop any subscriptsions
if sub is not None:
try:
sub.unsubscribe()
except:
log("Sonos: Failed to unsubscribe: %s" % traceback.format_exc(), xbmc.LOGERROR)
try:
# Make sure the thread is stopped even if unsubscribe failed
event_listener.stop()
except:
log("Sonos: Failed to stop event listener: %s" % traceback.format_exc(), xbmc.LOGERROR)
del sub
sonosCtrl.close()
示例6: __init__
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getIPAddress [as 别名]
def __init__(self):
# Check if the auto update IP is enabled
if not Settings.isAutoIpUpdateEnabled():
return
# Get the existing zone we are trying to set the IP Address for
existingZone = Settings.getZoneName()
# Nothing to do if there is no Zone name set
if (existingZone is None) or (existingZone == ""):
return
# Set up the logging before using the Sonos Device
SocoLogging.enable()
try:
sonos_devices = soco.discover()
except:
log("AutoUpdateIPAddress: Exception when getting devices")
log("AutoUpdateIPAddress: %s" % traceback.format_exc())
sonos_devices = []
ipaddresses = []
# Check each of the devices found
for device in sonos_devices:
ip = device.ip_address
log("AutoUpdateIPAddress: Getting info for IP address %s" % ip)
playerInfo = None
# Try and get the player info, if it fails then it is not a valid
# player and we should continue to the next
try:
playerInfo = device.get_speaker_info()
except:
log("AutoUpdateIPAddress: IP address %s is not a valid player" % ip)
log("AutoUpdateIPAddress: %s" % traceback.format_exc())
continue
# If player info was found, then print it out
if playerInfo is not None:
# What is the name of the zone that this speaker is in?
zone_name = playerInfo['zone_name']
# Check the zone against the ones we are looking for
if zone_name == existingZone:
# There could be multiple IP addressing in the same group
# so save them all
log("AutoUpdateIPAddress: IP address %s in zone %s" % (ip, existingZone))
ipaddresses.append(ip)
# Check if there is an IP Address to set
if len(ipaddresses) > 0:
oldIp = Settings.getIPAddress()
# Check if we already have a match to the existing IP Address
matchesExisting = False
for newIp in ipaddresses:
if newIp == oldIp:
matchesExisting = True
break
# If no match found - then set to the first IP Address
if not matchesExisting:
log("AutoUpdateIPAddress: Setting IP address to %s" % ipaddresses[0])
Settings.setIPAddress(ipaddresses[0])
示例7: log
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getIPAddress [as 别名]
log("SonosService: Currently playing artist = %s, album = %s, track = %s" % (track['artist'], track['album'], track['title']))
# Get the album art if it is set (Default to the Sonos icon)
albumArt = __icon__
if track['album_art'] != "":
albumArt = track['album_art']
# Gotham allows you to have a dialog without making a sound
xbmcgui.Dialog().notification(track['artist'], track['title'], albumArt, Settings.getNotificationDisplayDuration(), False)
else:
sonosPopup = SonosPlayingPopup.createSonosPlayingPopup(track)
sonosPopup.showPopup()
del sonosPopup
except:
# Connection failure - may just be a network glitch - so don't exit
log("SonosService: Error from speaker %s" % Settings.getIPAddress())
log("SonosService: %s" % traceback.format_exc())
# No longer the first start
justStartedService = False
# Reset the timer for the next check
timeUntilNextCheck = Settings.getNotificationCheckFrequency()
# Increment the timer and sleep for a second before the next check
xbmc.sleep(1000)
timeUntilNextCheck = timeUntilNextCheck - 1
del volumeLink
del autoPause
log("Sonos: Stopping service")