Changeset - f85304fdc975
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 15 years ago 2010-06-22 02:27:30
drewp@bigasterisk.com
cleanup no-song logic
Ignore-this: e03fc8ed94bbda94c63ae947ab4939bd
1 file changed with 1 insertions and 4 deletions:
0 comments (0 inline, 0 general)
light9/vidref/replay.py
Show inline comments
 
@@ -29,43 +29,40 @@ class ReplayViews(object):
 
        self.views = []
 
     
 
    def update(self, position):
 
        """
 
        freshen all replay windows. We get called this about every
 
        time there's a new live video frame.
 

	
 
        Calls loadViewsForSong if we change songs, or even if we just
 
        restart the playback of the current song (since there could be
 
        a new replay view)
 
        """
 
        t1 = time.time()
 
        if position.get('started') != self.lastStart:
 
        if position.get('started') != self.lastStart and position['song']:
 
            self.loadViewsForSong(position['song'])
 
            self.lastStart = position['started']
 
        for v in self.views:
 
            v.updatePic(position)
 
        log.debug("update %s views in %.2fms",
 
                  len(self.views), (time.time() - t1) * 1000)
 

	
 
    def loadViewsForSong(self, song):
 
        """
 
        replace previous views, and cleanup short ones
 
        """
 
        for v in self.views:
 
            v.destroy()
 
        self.views[:] = []
 

	
 
        if not song:
 
            return
 
        
 
        d = songDir(song)
 
        try:
 
            takes = sorted(t for t in os.listdir(d) if t.isdigit())
 
        except OSError:
 
            return
 
        
 
        for take in takes:
 
            td = takeDir(songDir(song), take)
 
            r = Replay(td)
 
            if r.tooShort():
 
                log.warn("cleaning up %s; too short" % r.takeDir)
 
                r.deleteDir()
0 comments (0 inline, 0 general)