当前位置: 首页>>代码示例>>Python>>正文


Python util.safe_str函数代码示例

本文整理汇总了Python中mythbox.util.safe_str函数的典型用法代码示例。如果您正苦于以下问题:Python safe_str函数的具体用法?Python safe_str怎么用?Python safe_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了safe_str函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getUpcomingRecordings

    def getUpcomingRecordings(self, filter=Upcoming.SCHEDULED):
        """
        @type filter: UPCOMING_*
        @rtype: RecordedProgram[]
        """
        upcoming = []
        reply = self._sendRequest(self.cmdSock, ['QUERY_GETALLPENDING', '2'])
        
        log.debug('getUpcomingRecordings reply begin= %s' % safe_str(reply[:80]))
        log.debug('getUpcomingRecordings reply end  = %s' % safe_str(reply[-80:]))
        
        numRows = int(reply[1])
        offset = 2

        from mythbox.mythtv.domain import RecordedProgram
        for i in xrange(numRows):
            program = RecordedProgram(
                    reply[offset:offset+self.protocol.recordSize()],
                    self.settings, 
                    self.translator,
                    self.platform,
                    self.protocol,
                    [self, None][self._db is None])
            if program.getRecordingStatus() in filter:
                upcoming.append(program)
            offset += self.protocol.recordSize()
        return upcoming
开发者ID:ReSearchITEng,项目名称:allinclusive-kodi-pi,代码行数:27,代码来源:conn.py

示例2: work

 def work(p):
     posters = provider.getPosters(p)
     if len(posters) == 0:
         log.exception('Failed on %s' % safe_str(p.title()))
         self.fail = True
     for poster in posters:
         log.debug('%s - %s' % (safe_str(p.title()), poster))
开发者ID:Berimor66,项目名称:mythbox,代码行数:7,代码来源:test_fanart.py

示例3: renderProgramInfo

 def renderProgramInfo(self, program):
     if program:
         log.debug('Show info for ' + safe_str(program.title()))
         self.setWindowProperty('title', program.fullTitle())
         self.setWindowProperty('category', program.category())
         self.setWindowProperty('description', program.description())
         self.setWindowProperty('subtitle', program.subtitle())
         self.setWindowProperty('airtime', program.formattedAirTime())
         self.setWindowProperty('duration', program.formattedDuration())
         self.setWindowProperty('originalAirDate', program.formattedOriginalAirDate())
         self.setWindowProperty('banner', u'')
         if self.fanArt.hasBanners(program):
             bannerPath = self.fanArt.pickBanner(program)
             self.setWindowProperty('banner', [u'',bannerPath][bannerPath is not None])
         else:
             log.debug('Added to bannerqueue: %s' % safe_str(program.title()))
             self.bannerQueue.put(program)
     else:
         self.setWindowProperty('title', u'')
         self.setWindowProperty('category', u'')
         self.setWindowProperty('description', u'')
         self.setWindowProperty('subtitle', u'')
         self.setWindowProperty('airtime', u'')
         self.setWindowProperty('duration', u'')
         self.setWindowProperty('originalAirDate', u'')
         self.setWindowProperty('banner', u'')
开发者ID:070499,项目名称:repo-scripts,代码行数:26,代码来源:tvguide.py

示例4: addJob

    def addJob(self, job):
        '''Add a new job to the job queue'''        
        sql = """INSERT INTO jobqueue (
                    chanid,
                    starttime,
                    type,
                    inserttime,
                    hostname, 
                    status,
                    comment, 
                    schedruntime)
                VALUES (%s, %s, %s, %s, %s, %s, %s, %s)"""
        
        log.debug("sql = %s" % safe_str(sql))
        args = (job.channelId, job.startTime, job.jobType, job.insertTime, job.hostname, job.jobStatus, job.comment, datetime.datetime.now(),)

        if log.isEnabledFor(logging.DEBUG):
            for i,arg in enumerate(args):
                log.debug('Positional arg %d: %s' % (i,safe_str(arg)))

        c = self.conn.cursor(*cursorArgs)       
        try:
            c.execute(sql, args)
        finally:
            c.close()

        if job.id is None:
            c2 = self.conn.cursor(*cursorArgs)
            try:
                c2.execute("select max(id) from jobqueue")
                job.id = c2.fetchall()[0][0]
                log.debug('New job id = %s' % job.id)
            finally:
                c2.close()
开发者ID:070499,项目名称:repo-scripts,代码行数:34,代码来源:db.py

示例5: get

 def get(self, fileUrl):
     """
     @return: local path if file resolution was successful, None otherwise
     """
     filepath = self._mapToPath(fileUrl) 
     if not os.path.exists(filepath) or os.path.getsize(filepath) == 0:
         log.debug('Cache MISS %s' % safe_str(fileUrl))
         
         self.lockResource(fileUrl)
         try:
             if not self.contains(fileUrl): 
                 self.resolver.store(fileUrl, filepath)
         finally:
             self.unlockResource(fileUrl)
         
         # Don't cache zero byte files
         if not os.path.exists(filepath):
             log.warn('File could not be resolved: %s and not at path: %s' % (safe_str(fileUrl), filepath) )
             return None
         
         if os.path.getsize(filepath) == 0:
             log.warn('file %s resulted in zero byte file...removing...' % safe_str(fileUrl))
             self.remove(fileUrl)
             return None
     else:
         if log.isEnabledFor(logging.DEBUG):
             if hasattr(fileUrl, 'title'):
                 s = fileUrl.title()
             elif hasattr(fileUrl, 'getChannelName'):
                 s = fileUrl.getChannelName()
             else:
                 s = fileUrl
             #log.debug('Cache HIT %s ' % safe_str(s))
     return filepath
开发者ID:Jajcus,项目名称:mythbox,代码行数:34,代码来源:filecache.py

示例6: getPosters

    def getPosters(self, program):
        posters = []
        if program.isMovie():
            try:
                results = self.mdb.search(program.title())
                if results and len(results) > 0:
                    filmId = results[0]['id']
                    film = self.mdb.getMovieInfo(filmId)
                    
                    for id in film['images']['poster']:
                        if 'mid' in film['images']['poster'][id]:
                        #for size in film['images']['poster'][id]:
                            size = 'mid'
                            url = film['images']['poster'][id][size]
                            #log.debug('TMDB: %s size = %s  url = %s' % (id, size, url))
                            posters.append(url)

                    #for i, result in enumerate(results):    
                        # Poster keys: 
                        #    'cover'      -- little small - 185px by 247px 
                        #    'mid'        -- just right   - 500px by 760px
                        #    'original'   -- can be huge  - 2690px by 3587px
                        #    'thumb'      -- tiny         - 92px by 136px
                        
                        #for key, value in result['poster'].items():
                        #    log.debug('TMDB: %d key = %s  value = %s' % (i, key, value))

                        #if  'mid' in result['poster']:
                        #    posters.append(result['poster']['mid'])
                else:
                    log.debug('TMDB: Found nothing for: %s' % safe_str(program.title()))
            except Exception, e:
                log.exception('TMDB: Fanart search error: %s %s' % (safe_str(program.title()), safe_str(e)))
开发者ID:aroth-arsoft,项目名称:mythbox,代码行数:33,代码来源:fanart.py

示例7: queryTvRage

 def queryTvRage(self, program):
     try:
         show = self.indexEpisodes(tvrage.api.Show(program.title()))
         self.save(program, show)
         return self.searchForEpisode(program, show)
     except tvrage.api.ShowNotFound:
         log.debug('TVRage: Show not found - %s' % safe_str(program.title()))
         return None, None
     except KeyError, ke:
         # TVRage throws KeyError on last line of constructor for incomplete
         # datasets
         log.warn('TVRage: KeyError %s - %s' % (safe_str(ke), safe_str(program.title())))
         return None, None
开发者ID:070499,项目名称:repo-scripts,代码行数:13,代码来源:fanart.py

示例8: getBackgrounds

 def getBackgrounds(self, program):
     backgrounds = []
     if not program.isMovie():
         t = self.transform(program.title())
         try:
             backgroundsByDimension = self._queryTvDb(t, qtype='fanart')
             for knownDim in ['1280x720', '1920x1080']:
                 if knownDim in backgroundsByDimension:
                     backgroundsById = backgroundsByDimension[knownDim]
                     for id in backgroundsById.keys():
                         backgrounds.append(backgroundsById[id]['_bannerpath'])
         except Exception, e:
             log.debug('TVDB: No backgrounds for %s - %s' % (safe_str(t), safe_str(e)))
开发者ID:Berimor66,项目名称:mythbox,代码行数:13,代码来源:fanart.py

示例9: queryTvRage

 def queryTvRage(self, program):
     try:
         show = self.indexEpisodes(tvrage.api.Show(program.title()))
         self.save(program, show)
         return self.searchForEpisode(program, show)
     except tvrage.api.ShowNotFound:
         log.debug('TVRage: Show not found - %s' % safe_str(program.title()))
         return None, None
     except TypeError, te:
         #  File "tvrage/api.py", line 145, in __init__
         #    for season in eplist:
         #TypeError: iteration over non-sequence
         log.exception('TVRage: TypeError %s - %s' % (safe_str(te), safe_str(program.title())))
         return None, None
开发者ID:aroth-arsoft,项目名称:mythbox,代码行数:14,代码来源:fanart.py

示例10: renderBanners

 def renderBanners(self, myRenderToken):
     log.debug('---- RENDER BANNER BEGIN ----')
     for channel, li in self.listItemsByChannel.items():
         if self.closed or xbmc.abortRequested or myRenderToken != self.activeRenderToken:
             return
         if channel.currentProgram and channel.needsBanner:
             channel.needsBanner = False
             bannerPath = self.fanArt.pickBanner(channel.currentProgram)
             if bannerPath:
                 log.debug('setting banner for %s to %s' % (safe_str(channel.currentProgram.title()), bannerPath))
                 self.updateListItemProperty(li, 'banner', bannerPath)
             else:
                 log.debug('no banner for %s' % safe_str(channel.currentProgram.title()))
     log.debug('---- RENDER BANNER END ----')
开发者ID:Jajcus,项目名称:mythbox,代码行数:14,代码来源:livetv.py

示例11: getPosters

 def getPosters(self, program):
     posters = []
     if program.isMovie():
         try:
             movies = self.imdb.search_movie(title=u'' + program.title(), results=1)
             for movie in movies:
                 m = self.imdb.get_movie(movie.getID())
                 #for key,value in m.items():
                 #    log.warn('movie[%d] id[%s] key[%s] -> %s' % (1, m.getID(), key, safe_str(value)))
                 posters.append(m['full-size cover url'])  
         except imdb.IMDbError, e:
             log.error('IMDB error looking up movie: %s %s' % (safe_str(program.title()), safe_str(str(e))))
         except Exception, e:
             log.error('IMDB error looking up %s: %s' % (safe_str(program.title()), safe_str(str(e))))
开发者ID:070499,项目名称:repo-scripts,代码行数:14,代码来源:fanart.py

示例12: getBanners

 def getBanners(self, program):
     if program.isMovie(): 
         return []
     
     banners = []
     t = self.transform(program.title())
     try:
         bannersByType = self._queryTvDb(t, qtype='series')
         for subType in ['graphical', 'text', 'blank']:
             if subType in bannersByType:
                 bannersById = bannersByType[subType]
                 for id in bannersById.keys():
                     banners.append(bannersById[id]['_bannerpath'])
     except Exception, e:
         log.warn('TVDB: No banners for %s - %s' % (safe_str(t), safe_str(e)))
开发者ID:Berimor66,项目名称:mythbox,代码行数:15,代码来源:fanart.py

示例13: renderGroups

    def renderGroups(self):
        lastSelectedIndex = 0
        self.groupsListItems = []
        
        sortedGroups = self.groupsByTitle.values()[:]
        sortedGroups.sort(key=self.GROUP_SORT_BY[self.groupSortBy]['sorter'], reverse=self.GROUP_SORT_BY[self.groupSortBy]['reverse'])
                    
        for i, group in enumerate(sortedGroups):
            title = group.title
  
            #log.debug('YYY %s %s' % (type(title), safe_str(title)))
            #log.debug('ZZZ %s %s' % (type(group.title), safe_str(group.title)))
            
            group.listItem = xbmcgui.ListItem()
            group.index = i
            self.groupsListItems.append(group.listItem)
            self.setListItemProperty(group.listItem, 'index', str(i))
            self.setListItemProperty(group.listItem, 'title', title)
            self.setListItemProperty(group.listItem, 'num_episodes', str(len(group.programs)))

            #vtitle = group.listItem.getProperty('title')
            #log.debug('\n\nAAA %s %s\n' % (type(vtitle), safe_str(vtitle)))

            if self.lastSelectedGroup == title:
                lastSelectedIndex = i
                log.debug('Last selected group index = %s %s' % (safe_str(title), lastSelectedIndex))

        self.groupsListbox.reset()
        self.groupsListbox.addItems(self.groupsListItems)
        self.selectListItemAtIndex(self.groupsListbox, lastSelectedIndex)
        
        log.debug('index check = %s' % self.groupsListbox.getSelectedPosition())
        self.onGroupSelect()
开发者ID:analogue,项目名称:mythbox,代码行数:33,代码来源:recordings.py

示例14: renderCoverFlow

    def renderCoverFlow(self, exclude=None):
        log.debug('>>> renderCoverFlow begin')
        self.recordings = self.conn().getAllRecordings()
        
        if exclude:
            try:
                self.recordings.remove(exclude)
            except:
                pass
        
        self.coverItems = []
            
        for i, r in enumerate(self.recordings[:MAX_COVERFLOW]):
            log.debug('Coverflow %d/%d: %s' % (i+1, MAX_COVERFLOW, safe_str(r.title())))
            listItem = xbmcgui.ListItem() 
            self.setListItemProperty(listItem, 'title', r.title())
            self.setListItemProperty(listItem, 'description', r.description())
            
            cover = self.fanArt.pickPoster(r)
            if not cover:
                cover = self.mythThumbnailCache.get(r)
                if not cover:
                    cover = 'mythbox-logo.png'
            self.updateListItemProperty(listItem, 'thumb', cover)
            self.coverItems.append(listItem)

        # NOTE: apparently, updating listitem properties broke in eden creating dupes.
        #       reset as a workaround for the time being.
        self.coverFlow.reset()
        self.coverFlow.addItems(self.coverItems)
        log.debug('<<< renderCoverFlow end')
开发者ID:ReSearchITEng,项目名称:allinclusive-kodi-pi,代码行数:31,代码来源:home.py

示例15: startup

 def startup(self):
     """
     @return: True if startup successful, False otherwise
     """
     self.settingsOK = False
     try:
         self.settings.verify()
         self.settingsOK = True
     except SettingsException, se:
         showPopup(self.t(m.ERROR), safe_str(se), 7000)
         if se.wakeup and self.settings.get("wakeup_command"):
             showPopup(self.t(m.INFO), "Waking the backend up", 7000)
             subprocess.call(self.settings.get("wakeup_command"),
                             shell=True)
             time.sleep(int(self.settings.get("wakeup_wait")))
             try:
                 self.settings.verify()
                 self.settingsOK = True
             except SettingsException:
                 pass
         if not self.settingsOK:
             self.goSettings()
             try:
                 self.settings.verify() # TODO: optimize unnecessary re-verify
                 self.settingsOK = True
             except SettingsException:
                 self.shutdown()
                 self.close()
                 return False
开发者ID:Jajcus,项目名称:mythbox,代码行数:29,代码来源:home.py


注:本文中的mythbox.util.safe_str函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。