Ensure files are not left open

This commit is contained in:
Nick Hall 2016-05-27 22:50:05 +01:00
parent b66a7a93c2
commit c4cab2e007

View File

@ -226,11 +226,13 @@ class CLIDbManager:
dirpath = os.path.join(dbdir, dpath) dirpath = os.path.join(dbdir, dpath)
path_name = os.path.join(dirpath, NAME_FILE) path_name = os.path.join(dirpath, NAME_FILE)
try: try:
backend_type = open(os.path.join(dirpath, "database.txt")).read() with open(os.path.join(dirpath, "database.txt")) as file:
backend_type = file.read()
except: except:
backend_type = "bsddb" backend_type = "bsddb"
try: try:
version = open(os.path.join(dirpath, "bdbversion.txt")).read() with open(os.path.join(dirpath, "bdbversion.txt")) as file:
version = file.read()
except: except:
version = "(0, 0, 0)" version = "(0, 0, 0)"
try: try: