From e5015d85b99fd2cea9c923da11e56fab4ac68fe6 Mon Sep 17 00:00:00 2001 From: hsoft Date: Wed, 2 Sep 2009 10:21:11 +0000 Subject: [PATCH] [#41 state:fixed] Added error handling + logging for GetDisplayInfo() --HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%40110 --- base/py/app.py | 11 ++++++++++- base/py/app_cocoa.py | 6 +++--- base/py/data.py | 4 +--- base/py/data_me.py | 4 +--- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/base/py/app.py b/base/py/app.py index 5e36eaad..004e31d7 100644 --- a/base/py/app.py +++ b/base/py/app.py @@ -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) diff --git a/base/py/app_cocoa.py b/base/py/app_cocoa.py index 48b23a11..7e4e68d3 100644 --- a/base/py/app_cocoa.py +++ b/base/py/app_cocoa.py @@ -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: diff --git a/base/py/data.py b/base/py/data.py index d0faf479..49f5fbf0 100644 --- a/base/py/data.py +++ b/base/py/data.py @@ -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 diff --git a/base/py/data_me.py b/base/py/data_me.py index b05dcf18..ab4d9dbf 100644 --- a/base/py/data_me.py +++ b/base/py/data_me.py @@ -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