本文整理汇总了Python中xbmc.sleep方法的典型用法代码示例。如果您正苦于以下问题:Python xbmc.sleep方法的具体用法?Python xbmc.sleep怎么用?Python xbmc.sleep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xbmc
的用法示例。
在下文中一共展示了xbmc.sleep方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def list(uri):
# Create instance of Engine
engine = Engine(uri)
files = []
# Ensure we'll close engine on exception
with closing(engine):
# Start engine
engine.start()
# Wait until files received
while not files and not xbmc.abortRequested:
# Will list only video files in torrent
files = engine.list(media_types=[MediaType.VIDEO])
# Check if there is loading torrent error and raise exception
engine.check_torrent_error()
xbmc.sleep(200)
return files
示例2: _connect_server
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def _connect_server(self, server_id):
server = self.connect_manager.get_server_info(server_id)
self.message.setLabel("%s %s..." % (_(30610), server['Name']))
self.message_box.setVisibleCondition('true')
self.busy.setVisibleCondition('true')
result = self.connect_manager['connect-to-server'](server)
if result['State'] == CONNECTION_STATE['Unavailable']:
self.busy.setVisibleCondition('false')
self.message.setLabel(_(30609))
return False
else:
xbmc.sleep(1000)
self._selected_server = result['Servers'][0]
return True
示例3: play_video
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def play_video(video_url = common.args.url):
hbitrate = -1
sbitrate = int(addon.getSetting('quality')) * 1024
closedcaption = None
video_data = connection.getURL(video_url)
video_tree = BeautifulSoup(video_data, 'html.parser')
finalurl = video_tree.video['src']
try:
closedcaption = video_tree.find('textstream', type = 'text/vtt')['src']
except:
pass
if (addon.getSetting('enablesubtitles') == 'true') and (closedcaption is not None):
convert_subtitles(closedcaption)
xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
if (addon.getSetting('enablesubtitles') == 'true') and (closedcaption is not None):
while not xbmc.Player().isPlaying():
xbmc.sleep(100)
xbmc.Player().setSubtitles(ustvpaths.SUBTITLE)
示例4: deleteFile
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def deleteFile(filename):
log('Deleting %s' % filename)
if len(filename) < 1:
log('Empty filename')
return
try: current = xbmc.Player().getPlayingFile() if xbmc.Player().isPlaying() else ''
except: current = ''
while current == filename:
try: current = xbmc.Player().getPlayingFile() if xbmc.Player().isPlaying() else ''
except: current = ''
xbmc.sleep(1000)
tries = 15
while xbmcvfs.exists(filename) and tries > 0:
tries -= 1
try:
xbmcvfs.delete(filename)
except Exception, e:
log('ERROR %s in deleteFile %s' % (str(e), filename))
log('ERROR tries=%d' % tries)
xbmc.sleep(500)
示例5: stopDownloaders
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def stopDownloaders():
log('in STOPDOWNLOADERS')
#signal all downloaders to stop
for i in range(MAX_DOWNLOADERS):
state = xbmcgui.Window(10000).getProperty(PROPERTY % i)
if state:
xbmcgui.Window(10000).setProperty(PROPERTY % i, 'Signal')
#now wait for them to all stop
i = 0
while i < MAX_DOWNLOADERS:
state = xbmcgui.Window(10000).getProperty(PROPERTY % i)
if state:
xbmc.sleep(100)
i = 0
else:
i += 1
示例6: Authorization
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def Authorization(verification_url, user_code, device_code):
pDialog = xbmcgui.DialogProgress()
pDialog.create(__scriptname__, "%s: %s" % (__language__(33806), verification_url), "%s: %s" % (__language__(33807), user_code))
for i in range(0, 100):
pDialog.update(i)
xbmc.sleep(5000)
if pDialog.iscanceled(): return
_authorize = Authorize(device_code)
if _authorize.is_authorized:
__addon__.setSetting('token', _authorize.access_token)
user = GetUserInformations(_authorize.access_token)
if user.is_authenticated:
if __welcome__ == 'true':
xbmcgui.Dialog().ok(__scriptname__, '%s %s' % (__language__(32902), user.username), __language__(33808))
__addon__.setSetting('user', user.username)
return
pDialog.close()
示例7: onInit
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def onInit(self):
Logutil.log("Begin onInit", util.LOG_LEVEL_INFO)
if self.quit:
Logutil.log("RCB decided not to run. Bye.", util.LOG_LEVEL_INFO)
self.close()
return
self.load_color_schemes()
self.clearList()
xbmc.sleep(util.WAITTIME_UPDATECONTROLS)
#reset last view
self.loadViewState()
Logutil.log("End onInit", util.LOG_LEVEL_INFO)
示例8: onPlayBackStopped
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def onPlayBackStopped(self):
self._playbackLock = False
url = "http://" + LOCAL_IP + ":" + str(VIDEO_PORT) + "/"
xbmc.sleep(300)
if os.path.exists("/proc/" + str(self.spsc_pid)) and xbmc.getCondVisibility(
"Window.IsActive(epg.xml)") and settings.getSetting('safe_stop') == "true":
if not xbmc.Player().isPlaying():
player = streamplayer(spsc_pid=self.spsc_pid, listitem=self.listitem)
player.play(url, self.listitem)
else:
try:
os.kill(self.spsc_pid, 9)
except:
pass
try:
xbmcvfs.delete(os.path.join(pastaperfil, 'sopcast.avi'))
except:
pass
示例9: handle_wait
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def handle_wait(time_to_wait,title,text,segunda=''):
ret = mensagemprogresso.create(' '+title)
secs=0
percent=0
increment = int(100 / time_to_wait)
cancelled = False
while secs < time_to_wait:
secs = secs + 1
percent = increment*secs
secs_left = str((time_to_wait - secs))
if segunda=='': remaining_display = translate(30070) + str(secs_left) + translate(30071)
else: remaining_display=segunda
mensagemprogresso.update(percent,text,remaining_display)
xbmc.sleep(1000)
if (mensagemprogresso.iscanceled()):
cancelled = True
break
if cancelled == True:
return False
else:
mensagemprogresso.close()
return False
示例10: on_playback_started
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def on_playback_started(self, player_state):
xbmc.sleep(500) # Wait for slower systems
self.player_state = player_state
if self.kodi_only_forced_subtitles and g.ADDON.getSettingBool('forced_subtitle_workaround')\
and self.sc_settings.get('subtitleenabled') is None:
# Use the forced subtitle workaround if enabled
# and if user did not change the subtitle setting
self._show_only_forced_subtitle()
for stype in sorted(STREAMS):
# Save current stream info from the player to local dict
self._set_current_stream(stype, player_state)
# Restore the user choice
self._restore_stream(stype)
# It is mandatory to wait at least 1 second to allow the Kodi system to update the values
# changed by restore, otherwise when _on_tick is executed it will save twice unnecessarily
xbmc.sleep(1000)
示例11: _update_library
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def _update_library(videoids_to_update, exported_tvshows_videoids_values, silent):
execute_lib_tasks_method = execute_library_tasks_silently if silent else execute_library_tasks
# Get the list of the Tv Shows exported to exclude from updates
excluded_videoids_values = g.SHARED_DB.get_tvshows_id_list(VidLibProp['exclude_update'], True)
for videoid in videoids_to_update:
# Check if current videoid is excluded from updates
if int(videoid.value) in excluded_videoids_values:
continue
if int(videoid.value) in exported_tvshows_videoids_values:
# It is possible that the user has chosen not to export NFO files for a tv show
nfo_export = g.SHARED_DB.get_tvshow_property(videoid.value,
VidLibProp['nfo_export'], False)
nfo_settings = nfo.NFOSettings(nfo_export)
else:
nfo_settings = nfo.NFOSettings()
if videoid.mediatype == common.VideoId.SHOW:
export_new_episodes(videoid, silent, nfo_settings)
if videoid.mediatype == common.VideoId.MOVIE:
execute_lib_tasks_method(videoid, [export_item], nfo_settings=nfo_settings)
# Add some randomness between operations to limit servers load and ban risks
xbmc.sleep(random.randint(1000, 5001))
示例12: delete_folder_contents
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def delete_folder_contents(path, delete_subfolders=False):
"""
Delete all files in a folder
:param path: Path to perform delete contents
:param delete_subfolders: If True delete also all subfolders
"""
directories, files = list_dir(path)
for filename in files:
xbmcvfs.delete(os.path.join(path, filename))
if not delete_subfolders:
return
for directory in directories:
delete_folder_contents(os.path.join(path, directory), True)
# Give time because the system performs previous op. otherwise it can't delete the folder
xbmc.sleep(80)
xbmcvfs.rmdir(os.path.join(path, directory))
示例13: fixKeymaps
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def fixKeymaps():
# Fix the keymap file name if it's been changed or the old name was being used
name = getKeyMapsFileName()
old = getOldKeyMapsFileName()
dir = getKeyMapsPath("*")
full_name = getKeyMapsPath(name)
try:
debugTrace("Getting contents of keymaps directory " + dir)
files = (glob.glob(dir))
if not full_name in files and len(files) > 0:
for file in files:
if (name in file) or (old in file):
infoTrace("common.py", "Renaming " + file + " to " + full_name)
xbmcvfs.rename(file, full_name)
xbmc.sleep(100)
# Wait 10 seconds for rename to happen otherwise quit and let it fail in the future
for i in range(0, 9):
if xbmcvfs.exists(full_name): break
xbmc.sleep(1000)
return True
except Exception as e:
errorTrace("common.py", "Problem fixing the keymap filename.")
errorTrace("common.py", str(e))
return False
示例14: startService
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def startService():
# Routine for config to call to request that service starts. Can time out if there's no response
# Return true if the check should be bypassed
if xbmcgui.Window(10000).getProperty("VPN_Manager_Service_Control") == "ignore": return True
# Check to see if service is not already running (shouldn't be...)
if not xbmcgui.Window(10000).getProperty("VPN_Manager_Service_Control") == "stopped": return True
debugTrace("Requesting service restarts")
# Update start property and wait for service to respond or timeout
xbmcgui.Window(10000).setProperty("VPN_Manager_Service_Control", "start")
for i in range (0, 30):
xbmc.sleep(1000)
if xbmcgui.Window(10000).getProperty("VPN_Manager_Service_Control") == "started": return True
# No response in 30 seconds, service is probably dead
errorTrace("common.py", "Couldn't communicate with VPN monitor service, didn't acknowledge a start")
return False
示例15: stopService
# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import sleep [as 别名]
def stopService():
# Routine for config to call to request service stops and waits until that happens
# Return true if the check should be bypassed
if xbmcgui.Window(10000).getProperty("VPN_Manager_Service_Control") == "ignore": return True
# Check to see if the service has stopped previously
if xbmcgui.Window(10000).getProperty("VPN_Manager_Service_Control") == "stopped": return True
debugTrace("Requesting service stops")
# Update start property and wait for service to respond or timeout
xbmcgui.Window(10000).setProperty("VPN_Manager_Service_Control", "stop")
for i in range (0, 30):
xbmc.sleep(1000)
if xbmcgui.Window(10000).getProperty("VPN_Manager_Service_Control") == "stopped": return True
# Haven't had a response in 30 seconds which is badness
errorTrace("common.py", "Couldn't communicate with VPN monitor service, didn't acknowledge a stop")
return False