Fixes for Missed 'open' statements

This commit is contained in:
Eno 2016-04-27 08:11:58 +10:00 committed by Sam Manzi
parent a9685a64ff
commit 35b160ca0b

View File

@ -2537,9 +2537,9 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
schema_version = self.metadata.get(b'version', default=None)
bdbversion_file = os.path.join(self.path, BDBVERSFN)
if os.path.isfile(bdbversion_file):
vers_file = open(bdbversion_file)
bsddb_version = vers_file.readline().strip()
bsddb_version = ".".join([str(v) for v in safe_eval(bsddb_version)])
with open(bdbversion_file) as vers_file:
bsddb_version = vers_file.readline().strip()
bsddb_version = ".".join([str(v) for v in safe_eval(bsddb_version)])
else:
bsddb_version = _("Unknown")
return {
@ -2619,8 +2619,8 @@ def do_restore(database):
"""
for (base, tbl) in build_tbl_map(database):
backup_name = mk_backup_name(database, base)
backup_table = open(backup_name, 'rb')
load_tbl_txn(database, backup_table, tbl)
with open(backup_name, 'rb') as backup_table:
load_tbl_txn(database, backup_table, tbl)
database.rebuild_secondary()