def getCycleLock():
# If the lock is forced, don't wait, just return (ie don't queue)
if xbmcgui.Window(10000).getProperty("VPN_Manager_Cycle_Lock") == "Forced Locked" : return False
# If there's already a queue on the lock, don't wait, just return
if not xbmcgui.Window(10000).getProperty("VPN_Manager_Cycle_Lock_Queued") == "" : return False
# Loop until we get the lock or time out after 5 seconds
xbmcgui.Window(10000).setProperty("VPN_Manager_Cycle_Lock_Queued", "Queued")
i = 0
while i < 5 and not xbmcgui.Window(10000).getProperty("VPN_Manager_Cycle_Lock") == "":
xbmc.sleep(1000)
i = i + 1
# Free the queue so another call can wait on it
xbmcgui.Window(10000).setProperty("VPN_Manager_Cycle_Lock_Queued", "")
# Return false if a forced lock happened whilst we were queuing
if xbmcgui.Window(10000).getProperty("VPN_Manager_Cycle_Lock") == "Forced Locked" : return False
# Return false if the lock wasn't obtained because of a time out
if i == 5 : return False
xbmcgui.Window(10000).setProperty("VPN_Manager_Cycle_Lock", "Locked")
return True
评论列表
文章目录