workaroud for failure of loading setting

This commit is contained in:
tzutalin
2018-11-18 09:42:33 -08:00
parent 2df7b6e402
commit 699125aa5c
2 changed files with 23 additions and 12 deletions
+10 -6
View File
@@ -2,6 +2,7 @@ import pickle
import os
import sys
class Settings(object):
def __init__(self):
# Be default, the home will be in the same folder as labelImg
@@ -28,15 +29,18 @@ class Settings(object):
return False
def load(self):
if os.path.exists(self.path):
with open(self.path, 'rb') as f:
self.data = pickle.load(f)
return True
try:
if os.path.exists(self.path):
with open(self.path, 'rb') as f:
self.data = pickle.load(f)
return True
except:
print('Loading setting failed')
return False
def reset(self):
if os.path.exists(self.path):
os.remove(self.path)
print ('Remove setting pkl file ${0}'.format(self.path))
print('Remove setting pkl file ${0}'.format(self.path))
self.data = {}
self.path = None
self.path = None