python类sleep()的实例源码

common.py 文件源码 项目:service.vpn.manager 作者: Zomboided 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def writeCredentials(addon): 

    # Write the credentials file        
    try:
        credentials_path = getCredentialsPath(addon)
        debugTrace("Writing VPN credentials file to " + credentials_path)
        credentials = open(credentials_path,'w')
        credentials.truncate()
        credentials.close()
        credentials = open(credentials_path,'a')
        credentials.write(addon.getSetting("vpn_username")+"\n")
        credentials.write(addon.getSetting("vpn_password")+"\n")
        credentials.close()
    except Exception as e:
        errorTrace("common.py", "Couldn't create credentials file " + credentials_path)
        errorTrace("common.py", str(e))
        return False
    xbmc.sleep(500)
    return True
changelog.py 文件源码 项目:plugin.video.exodus 作者: lastship 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def get(version):
    try:
        import xbmc,xbmcgui,xbmcaddon,xbmcvfs

        f = xbmcvfs.File(xbmcaddon.Addon().getAddonInfo('changelog'))
        text = f.read() ; f.close()

        label = '%s - %s' % (xbmc.getLocalizedString(24054), xbmcaddon.Addon().getAddonInfo('name'))

        id = 10147

        xbmc.executebuiltin('ActivateWindow(%d)' % id)
        xbmc.sleep(100)

        win = xbmcgui.Window(id)

        retry = 50
        while (retry > 0):
            try:
                xbmc.sleep(10)
                win.getControl(1).setLabel(label)
                win.getControl(5).setText(text)
                retry = 0
            except:
                retry -= 1

        return '1'
    except:
        return '1'
player.py 文件源码 项目:plugin.video.exodus 作者: lastship 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def run(self, title, year, season, episode, imdb, tvdb, url, meta):
        try:
            control.sleep(200)

            self.totalTime = 0 ; self.currentTime = 0

            self.content = 'movie' if season == None or episode == None else 'episode'

            self.title = title ; self.year = year
            self.name = urllib.quote_plus(title) + urllib.quote_plus(' (%s)' % year) if self.content == 'movie' else urllib.quote_plus(title) + urllib.quote_plus(' S%02dE%02d' % (int(season), int(episode)))
            self.name = urllib.unquote_plus(self.name)
            self.season = '%01d' % int(season) if self.content == 'episode' else None
            self.episode = '%01d' % int(episode) if self.content == 'episode' else None

            self.DBID = None
            self.imdb = imdb if not imdb == None else '0'
            self.tvdb = tvdb if not tvdb == None else '0'
            self.ids = {'imdb': self.imdb, 'tvdb': self.tvdb}
            self.ids = dict((k,v) for k, v in self.ids.iteritems() if not v == '0')

            self.offset = bookmarks().get(self.name, self.year)

            poster, thumb, meta = self.getMeta(meta)

            item = control.item(path=url)
            item.setArt({'icon': thumb, 'thumb': thumb, 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster})
            item.setInfo(type='Video', infoLabels = meta)

            if 'plugin' in control.infoLabel('Container.PluginName'):
                control.player.play(url, item)

            control.resolve(int(sys.argv[1]), True, item)

            control.window.setProperty('script.trakt.ids', json.dumps(self.ids))

            self.keepPlaybackAlive()

            control.window.clearProperty('script.trakt.ids')
        except:
            return
player.py 文件源码 项目:plugin.video.exodus 作者: lastship 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def idleForPlayback(self):
        for i in range(0, 200):
            if control.condVisibility('Window.IsActive(busydialog)') == 1: control.idle()
            else: break
            control.sleep(100)
default.py 文件源码 项目:nuodtayo.tv 作者: benaranguren 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def show_message(message, title=xbmcaddon.Addon().getLocalizedString(50107)):
    if not message:
        return
    xbmc.executebuiltin("ActivateWindow(%d)" % (10147, ))
    win = xbmcgui.Window(10147)
    xbmc.sleep(100)
    win.getControl(1).setLabel(title)
    win.getControl(5).setText(message)
default.py 文件源码 项目:cmik.xbmc 作者: cmik 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def showMessage(message, title = lang(50001)):
    if not message:
        return
    xbmc.executebuiltin("ActivateWindow(%d)" % 10147)
    win = xbmcgui.Window(10147)
    xbmc.sleep(100)
    win.getControl(1).setLabel(title)
    win.getControl(5).setText(message)
backuprestore.py 文件源码 项目:script.skin.helper.skinbackup 作者: marcelveldt 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def create_temp():
        '''create temp folder for skin backup/restore'''
        temp_path = u'%stemp/' % ADDON_DATA
        # workaround weird slashes behaviour on some platforms.
        temp_path = temp_path.replace("//","/").replace("special:/","special://")
        if xbmcvfs.exists(temp_path):
            recursive_delete_dir(temp_path)
            xbmc.sleep(2000)
        xbmcvfs.mkdirs(temp_path)
        xbmcvfs.mkdirs(temp_path + "skinbackup/")
        return temp_path
backuprestore.py 文件源码 项目:script.skin.helper.skinbackup 作者: marcelveldt 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def restore_guisettings(self, filename, progressdialog):
        '''restore guisettings'''
        kodifile = xbmcvfs.File(filename, 'r')
        data = kodifile.read()
        importstring = eval(data)
        kodifile.close()
        xbmc.sleep(200)
        for count, skinsetting in enumerate(importstring):

            if progressdialog and progressdialog.iscanceled():
                return

            setting = skinsetting[1]
            settingvalue = skinsetting[2]

            if progressdialog:
                progressdialog.update((count * 100) / len(importstring),
                                      '%s %s' % (self.addon.getLocalizedString(32033), setting))

            if skinsetting[0] == "string":
                if settingvalue:
                    xbmc.executebuiltin("Skin.SetString(%s,%s)" % (setting, settingvalue))
                else:
                    xbmc.executebuiltin("Skin.Reset(%s)" % setting)
            elif skinsetting[0] == "bool":
                if settingvalue == "true":
                    xbmc.executebuiltin("Skin.SetBool(%s)" % setting)
                else:
                    xbmc.executebuiltin("Skin.Reset(%s)" % setting)
            xbmc.sleep(30)
utils.py 文件源码 项目:script.skin.helper.skinbackup 作者: marcelveldt 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def copy_file(source, destination, do_wait=False):
    '''copy a file on the filesystem, wait for the action to be completed'''
    if xbmcvfs.exists(destination):
        delete_file(destination)
    xbmcvfs.copy(source, destination)
    if do_wait:
        count = 20
        while count:
            xbmc.sleep(500)  # this first sleep is intentional
            if xbmcvfs.exists(destination):
                break
            count -= 1
utils.py 文件源码 项目:script.skin.helper.skinbackup 作者: marcelveldt 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def delete_file(filepath, do_wait=False):
    '''delete a file on the filesystem, wait for the action to be completed'''
    xbmcvfs.delete(filepath)
    if do_wait:
        count = 20
        while count:
            xbmc.sleep(500)  # this first sleep is intentional
            if not xbmcvfs.exists(filepath):
                break
            count -= 1
player_monitor.py 文件源码 项目:plugin.audio.spotify 作者: marcelveldt 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def fill_fake_buffer(self):
        '''emulate playback by just slowly reading the stdout'''
        # We could pick up this data in a buffer but it is almost impossible to keep it all in sync.
        # So instead we ignore the audio from the connect daemon completely and we
        # just launch a standalone instance to play the track
        while not self.__exit:
            line = self.__spotty_proc.stdout.readline()
            xbmc.sleep(1)
plugin_content.py 文件源码 项目:plugin.audio.spotify 作者: marcelveldt 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def next_track(self):
        '''special entry which tells the remote connect player to move to the next track'''
        # move to next track
        self.sp.next_track()
        # play next track
        xbmc.sleep(100)
        cur_playback = self.sp.current_playback()
        trackdetails = cur_playback["item"]
        url, li = parse_spotify_track(trackdetails, silenced=True)
        xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, li)
plugin_content.py 文件源码 项目:plugin.audio.spotify 作者: marcelveldt 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _fill_buffer(self):
        while self._running:
            self._buffer_lock.acquire()
            if len(self._buffer) <= self.MIN_BUFFER_SIZE:
                log_msg("Spotify radio track buffer was %d, below minimum size of %d - filling" %
                        (len(self._buffer), self.MIN_BUFFER_SIZE), xbmc.LOGDEBUG)
                self._buffer += self._fetch()
                self._buffer_lock.release()
            else:
                self._buffer_lock.release()
                time.sleep(self.CHECK_BUFFER_PERIOD)
gPlayer.py 文件源码 项目:Python-GoogleDrive-VideoStream 作者: ddurdle 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def playList(self, service):
        while self.current < len(self.mediaItems) and not self.isExit:
            self.playNext(service, self.mediaItems[self.current])
            current = self.current
            while current == self.current and not self.isExit:
                xbmc.sleep(3000)

        if self.service.settings:
            xbmc.log(self.service.addon.getAddonInfo('name') + ': Exit play list', xbmc.LOGNOTICE)

#    def onPlayBackSeek(self,offset):
gPlayer.py 文件源码 项目:Python-GoogleDrive-VideoStream 作者: ddurdle 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def seekTo(self, seek):
        if seek != '':
            self.seek = float(seek)
#        self.tvScheduler.setVideoWatched(self.worksheet, self.content[self.current][0])
        if seek > 0 and seek !='':
            while not self.isPlaying(): #<== The should be    while self.isPlaying():
                xbmc.sleep(500)
            xbmc.sleep(2000)
            self.time = float(seek)
            self.seekTime(float(seek))
            if self.service.settings:
                xbmc.log(self.service.addon.getAddonInfo('name') + ': Seek ' + str(self.time), xbmc.LOGNOTICE)
api.py 文件源码 项目:plugin.video.auvio 作者: rickybiscus 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_base_datas():
    """
    Fetch the header nav datas from API and clean it (menu items)
    """

    global main_data
    if main_data is None:

        site = 'media' # 'data-site' attr from body
        url = common.rtbf_url + 'news/api/menu?site=%s' % site 

        progressdialog = xbmcgui.DialogProgress()
        progressdialog.create(common.plugin.addon.getAddonInfo('name'))
        progressdialog.update(0, 'Récupération des données...')

        common.plugin.log("get_base_datas")

        try:

            json_data = utils.request_url(url)
            if not json_data:
                return

            main_data = json.loads(json_data) #will generate unicode
            main_data = clean_base_datas(main_data)
            progressdialog.update(100, 'Done!')

        except:
            main_data = False
            progressdialog.update(0, 'Échec!')
            xbmc.sleep(1000)

        progressdialog.close()

    #common.plugin.log("before clean_base_datas:")
    #common.plugin.log(json.dumps(main_data))

    #common.plugin.log("after clean_base_datas:")
    #common.plugin.log(json.dumps(main_data))

    return main_data
tweets.py 文件源码 项目:script.matchcenter 作者: enen92 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def onInit(self):
        xbmc.log(msg="[Match Center] Twitter cycle started", level=xbmc.LOGDEBUG)
        self.getControl(32540).setImage(os.path.join(addon_path,"resources","img","goal.png"))
        xbmc.executebuiltin("SetProperty(loading-script-matchcenter-twitter,1,home)")
        self.getTweets()
        xbmc.executebuiltin("ClearProperty(loading-script-matchcenter-twitter,Home)")
        i=0
        while self.isRunning:
            if (float(i*200)/(twitter_update_time*60*1000)).is_integer() and ((i*200)/(3*60*1000)) != 0:
                self.getTweets()
            xbmc.sleep(200)
            i += 1
        xbmc.log(msg="[Match Center] Twitter cycle stopped", level=xbmc.LOGDEBUG)
changelog.py 文件源码 项目:plugin.video.lastship 作者: lastship 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get(version):
    try:
        import xbmc,xbmcgui,xbmcaddon,xbmcvfs

        f = xbmcvfs.File(xbmcaddon.Addon().getAddonInfo('changelog'))
        text = f.read() ; f.close()

        label = '%s - %s' % (xbmc.getLocalizedString(24054), xbmcaddon.Addon().getAddonInfo('name'))

        id = 10147

        xbmc.executebuiltin('ActivateWindow(%d)' % id)
        xbmc.sleep(100)

        win = xbmcgui.Window(id)

        retry = 50
        while (retry > 0):
            try:
                xbmc.sleep(10)
                win.getControl(1).setLabel(label)
                win.getControl(5).setText(text)
                retry = 0
            except:
                retry -= 1

        return '1'
    except:
        return '1'
player.py 文件源码 项目:plugin.video.lastship 作者: lastship 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def run(self, title, year, season, episode, imdb, tvdb, url, meta):
        try:
            control.sleep(200)

            self.totalTime = 0 ; self.currentTime = 0

            self.content = 'movie' if season == None or episode == None else 'episode'

            self.title = title ; self.year = year
            self.name = urllib.quote_plus(title) + urllib.quote_plus(' (%s)' % year) if self.content == 'movie' else urllib.quote_plus(title) + urllib.quote_plus(' S%02dE%02d' % (int(season), int(episode)))
            self.name = urllib.unquote_plus(self.name)
            self.season = '%01d' % int(season) if self.content == 'episode' else None
            self.episode = '%01d' % int(episode) if self.content == 'episode' else None

            self.DBID = None
            self.imdb = imdb if not imdb == None else '0'
            self.tvdb = tvdb if not tvdb == None else '0'
            self.ids = {'imdb': self.imdb, 'tvdb': self.tvdb}
            self.ids = dict((k,v) for k, v in self.ids.iteritems() if not v == '0')

            self.offset = bookmarks().get(self.name, self.year)

            poster, thumb, meta = self.getMeta(meta)

            item = control.item(path=url)
            item.setArt({'icon': thumb, 'thumb': thumb, 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster})
            item.setInfo(type='Video', infoLabels = meta)

            if 'plugin' in control.infoLabel('Container.PluginName'):
                control.player.play(url, item)

            control.resolve(int(sys.argv[1]), True, item)

            control.window.setProperty('script.trakt.ids', json.dumps(self.ids))

            self.keepPlaybackAlive()

            control.window.clearProperty('script.trakt.ids')
        except:
            return


问题


面经


文章

微信
公众号

扫码关注公众号