From ba186ffd10662b08a87212c7257c12c1d3cc35fc Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 7 Nov 2011 12:09:38 +0100 Subject: [PATCH 1/3] avoid division by 0 --- pandora/archive/extract.py | 7 ++++--- pandora/clip/managers.py | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pandora/archive/extract.py b/pandora/archive/extract.py index 1c952ffe0..8fa9360cb 100644 --- a/pandora/archive/extract.py +++ b/pandora/archive/extract.py @@ -317,9 +317,10 @@ def average_color(prefix, start=0, end=0): if end: frames = end - start - for i in range(0, len(pixels)): - p = np.sum(pixels[i], axis=0) / frames - color += p + if frames: + for i in range(0, len(pixels)): + p = np.sum(pixels[i], axis=0) / frames + color += p color = list(map(float, color)) return ox.image.getHSL(color) diff --git a/pandora/clip/managers.py b/pandora/clip/managers.py index eae7e1f2a..82b02dec5 100644 --- a/pandora/clip/managers.py +++ b/pandora/clip/managers.py @@ -59,6 +59,9 @@ def parseCondition(condition, user): return ~q else: return q + if (not exclude and op == '=' or op in ('$', '^', '>=', '<')) and v == '': + return Q(True) + if k.endswith('__id'): v = decode_id(v) if isinstance(v, bool): #featured and public flag From ecf02a143a8fdb8a3f0cf99a23a82e115819a396 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 7 Nov 2011 12:31:20 +0100 Subject: [PATCH 2/3] fix color calculation off by one --- pandora/archive/extract.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandora/archive/extract.py b/pandora/archive/extract.py index 8fa9360cb..fc841b721 100644 --- a/pandora/archive/extract.py +++ b/pandora/archive/extract.py @@ -294,7 +294,7 @@ def average_color(prefix, start=0, end=0): timelines = sorted(filter(lambda t: t!= '%s%sp.png'%(prefix,height), glob("%s%sp*.png"%(prefix, height)))) for image in timelines: start_offset = 0 - if start and frames + 1500 < start: + if start and frames + 1500 <= start: frames += 1500 continue timeline = Image.open(image) @@ -311,7 +311,6 @@ def average_color(prefix, start=0, end=0): p = np.asarray(timeline.convert('RGB'), dtype=np.float32) p = np.sum(p, axis=0) / height #average color per frame pixels.append(p) - if end and frames >= end: break From 51f2e2a14cca66696eb6cad777eb8f14437952a8 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 7 Nov 2011 12:41:50 +0100 Subject: [PATCH 3/3] fix list defaults --- pandora/itemlist/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora/itemlist/models.py b/pandora/itemlist/models.py index fc8b47900..1a5986d82 100644 --- a/pandora/itemlist/models.py +++ b/pandora/itemlist/models.py @@ -34,8 +34,8 @@ class List(models.Model): icon = models.ImageField(default=None, blank=True, upload_to=lambda i, x: i.path("icon.jpg")) - view = models.TextField(default=lambda: settings.CONFIG['user']['ui']['listView']) - sort = TupleField(default=lambda: settings.CONFIG['user']['ui']['listSort'], editable=False) + view = models.TextField(default=lambda: tuple(settings.CONFIG['user']['ui']['listView'])) + sort = TupleField(default=lambda: tuple(settings.CONFIG['user']['ui']['listSort']), editable=False) poster_frames = TupleField(default=[], editable=False)