Announce to user on database shelve, the process can take a while especially with large dictionaries and slow systems and we don't want users thinking the app hung.

This commit is contained in:
Bill Dengler 2015-05-02 04:00:29 -04:00
parent 9d083fb550
commit 3a5eeed372

View File

@ -365,10 +365,12 @@ class Session(object):
"Shelve the database to allow for persistance." "Shelve the database to allow for persistance."
shelfname=paths.config_path(str(self.session_id)+".db") shelfname=paths.config_path(str(self.session_id)+".db")
try: try:
if not os.exists(shelfname):
output.speak("Generating database, this might take a while.",True)
shelf=shelve.open(paths.config_path(shelfname),'c') shelf=shelve.open(paths.config_path(shelfname),'c')
for key,value in self.db.items(): for key,value in self.db.items():
if type(key) != str and type(key) != unicode: if type(key) != str and type(key) != unicode:
output.speak("Uh oh, while shelving the database, a key of type " + str(type(key)) + " has been found. It will be converted to type str, but this will cause all sorts of problems on deshelve. Please bring this to the attention of the " + application.name + " developers immediately. More information about the error will be written to the error log.") output.speak("Uh oh, while shelving the database, a key of type " + str(type(key)) + " has been found. It will be converted to type str, but this will cause all sorts of problems on deshelve. Please bring this to the attention of the " + application.name + " developers immediately. More information about the error will be written to the error log.",True)
log.error("Uh oh, " + str(key) + " is of type " + str(type(key)) + "!") log.error("Uh oh, " + str(key) + " is of type " + str(type(key)) + "!")
shelf[str(key)]=value shelf[str(key)]=value
shelf.close() shelf.close()