[#41 state:fixed] Added error handling + logging for GetDisplayInfo()

--HG--
extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%40110
This commit is contained in:
hsoft 2009-09-02 10:21:11 +00:00
parent 44ecae2657
commit e5015d85b9
4 changed files with 15 additions and 10 deletions

View File

@ -87,6 +87,15 @@ class DupeGuru(RegistrableApplication):
for file in j.iter_with_progress(files, 'Reading metadata %d/%d'):
file._read_all_info(sections=[IT_ATTRS, IT_EXTRA])
def _get_display_info(self, dupe, group, delta=False):
if (dupe is None) or (group is None):
return ['---'] * len(self.data.COLUMNS)
try:
return self.data.GetDisplayInfo(dupe, group, delta)
except Exception as e:
logging.warning(u'Exception on GetDisplayInfo for %s: %s', unicode(dupe.path), unicode(e))
return ['---'] * len(self.data.COLUMNS)
def _get_file(self, str_path):
p = Path(str_path)
for d in self.directories:
@ -185,7 +194,7 @@ class DupeGuru(RegistrableApplication):
rows = []
for group in self.results.groups:
for dupe in group:
data = self.data.GetDisplayInfo(dupe, group)
data = self._get_display_info(dupe, group)
row = [data[colid] for colid in column_ids]
row.insert(0, dupe is not group.ref)
rows.append(row)

View File

@ -100,9 +100,9 @@ class DupeGuru(app.DupeGuru):
return self.GetDirectory(node_path[1:],d)
def RefreshDetailsTable(self,dupe,group):
l1 = self.data.GetDisplayInfo(dupe,group,False)
l1 = self._get_display_info(dupe, group, False)
if group is not None:
l2 = self.data.GetDisplayInfo(group.ref,group,False)
l2 = self._get_display_info(group.ref, group, False)
else:
l2 = l1 #To have a list of empty '---' values
names = [c['display'] for c in self.data.COLUMNS]
@ -265,7 +265,7 @@ class DupeGuru(app.DupeGuru):
else:
d = self.results.dupes[node_path[0]]
g = self.results.get_group_of_duplicate(d)
result = self.data.GetDisplayInfo(d, g, self.display_delta_values)
result = self._get_display_info(d, g, self.display_delta_values)
return result
elif tag == 1: #Directories
try:

View File

@ -53,9 +53,7 @@ COLUMNS = [
{'attr':'dupe_count','display':'Dupe Count'},
]
def GetDisplayInfo(dupe, group, delta=False):
if (dupe is None) or (group is None):
return ['---'] * len(COLUMNS)
def GetDisplayInfo(dupe, group, delta):
size = dupe.size
ctime = dupe.ctime
mtime = dupe.mtime

View File

@ -33,9 +33,7 @@ COLUMNS = [
{'attr':'dupe_count','display':'Dupe Count'},
]
def GetDisplayInfo(dupe, group, delta=False):
if (dupe is None) or (group is None):
return ['---'] * len(COLUMNS)
def GetDisplayInfo(dupe, group, delta):
size = dupe.size
duration = dupe.duration
bitrate = dupe.bitrate