From 92cd16bec9dcb5e7b947ccb3e9d4df76cb7fb1ca Mon Sep 17 00:00:00 2001 From: Bill Dengler Date: Tue, 12 May 2015 15:26:06 -0400 Subject: [PATCH] #33: Add is_audio rebuild method, to eliminate slowness as much as possible. --- src/sessionmanager/session.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/sessionmanager/session.py b/src/sessionmanager/session.py index e9498327..70793a5f 100644 --- a/src/sessionmanager/session.py +++ b/src/sessionmanager/session.py @@ -114,6 +114,7 @@ class Session(object): self.settings = config_utils.load_config(paths.config_path(file_), paths.app_path("Conf.defaults")) self.init_sound() self.deshelve() + self.tag_audio_tweets() # except: # log.exception("The session configuration has failed.") # self.settings = None @@ -408,3 +409,18 @@ class Session(object): output.speak("An exception occurred while deshelving the " + application.name + " database. It will be deleted and rebuilt automatically. If this error persists, send the error log to the " + application.name + " developers.",True) log.exception("Exception while deshelving" + shelfname) os.remove(shelfname) + + def tag_audio_tweets(self): + "Checks for missing audio tags and repairs them to improve performance." + missings=[] + for key,value in self.db.items(): + if type(value) == list: + for t in value: + if 'is_audio' not in t: + missings.append(t) + if len(missings) > 0: + output.speak(str(len(missings))+" tweets have missing audio tags. "+ application.name + " Will now repair all tags before starting. This may take a while.",True) + count=0 + for m in missings: + utils.is_audio(m) + output.speak("Tagged " + str(count) + " of " + str(len(missings))) \ No newline at end of file