Fixed shelve method

This commit is contained in:
Manuel Cortez 2021-01-27 17:31:14 -06:00
parent 36cc3f9365
commit eca0c0dbbd

View File

@ -75,7 +75,7 @@ class baseSession(object):
def shelve(self): def shelve(self):
"""Shelve the database to allow for persistance.""" """Shelve the database to allow for persistance."""
shelfname=os.path.join(paths.config_path(), str(self.session_id)+"/cache") shelfname=os.path.join(paths.config_path(), str(self.session_id), "cache")
if self.settings["general"]["persist_size"] == 0: if self.settings["general"]["persist_size"] == 0:
if os.path.exists(shelfname+".dat"): if os.path.exists(shelfname+".dat"):
os.remove(shelfname+".dat") os.remove(shelfname+".dat")
@ -84,7 +84,7 @@ class baseSession(object):
if not os.path.exists(shelfname+".dat"): if not os.path.exists(shelfname+".dat"):
output.speak("Generating database, this might take a while.",True) output.speak("Generating database, this might take a while.",True)
shelf=shelve.open(os.path.join(paths.config_path(), shelfname),'c') shelf=shelve.open(os.path.join(paths.config_path(), shelfname),'c')
for key,value in list(self.db.items()): for key, value in list(self.db.items()):
if type(key) != str and type(key) != str: if type(key) != str and type(key) != str:
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) 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)) + "!")