diff --git a/light9/vidref/main.py b/light9/vidref/main.py --- a/light9/vidref/main.py +++ b/light9/vidref/main.py @@ -51,16 +51,20 @@ class MusicTime(object): def _timeUpdate(self): while True: - position = jsonlib.loads(self.musicResource.get("time").body, - use_float=True) + try: + position = jsonlib.loads(self.musicResource.get("time").body, + use_float=True) - # this is meant to be the time when the server gave me its - # report, and I don't know if that's closer to the - # beginning of my request or the end of it (or some - # fraction of the way through) - self.positionFetchTime = time.time() - - self.position = position + # this is meant to be the time when the server gave me its + # report, and I don't know if that's closer to the + # beginning of my request or the end of it (or some + # fraction of the way through) + self.positionFetchTime = time.time() + + self.position = position + except restkit.RequestError, e: + log.error(e) + time.sleep(1) time.sleep(self.period) class VideoRecordSink(gst.Element): diff --git a/light9/vidref/replay.py b/light9/vidref/replay.py --- a/light9/vidref/replay.py +++ b/light9/vidref/replay.py @@ -182,6 +182,8 @@ class ReplayView(object): self.picWidget.queue_draw_area(0,0,320,240) self.picWidget.get_window().process_updates(True) self.showingPic = inPic + +_existingFrames = {} # takeDir : frames class Replay(object): """ @@ -189,8 +191,13 @@ class Replay(object): """ def __init__(self, takeDir): self.takeDir = takeDir - self.existingFrames = sorted([Decimal(f.split('.jpg')[0]) - for f in os.listdir(self.takeDir)]) + try: + self.existingFrames = _existingFrames[self.takeDir] + except KeyError: + log.info("scanning %s", self.takeDir) + self.existingFrames = sorted([Decimal(f.split('.jpg')[0]) + for f in os.listdir(self.takeDir)]) + _existingFrames[self.takeDir] = self.existingFrames def tooShort(self, minSeconds=5): return len(self.existingFrames) < (minSeconds * framerate)