removed chain_img
authorForrest Voight <forrest.voight@gmail.com>
Mon, 26 Mar 2012 13:43:30 +0000 (09:43 -0400)
committerForrest Voight <forrest@forre.st>
Thu, 5 Apr 2012 19:03:40 +0000 (15:03 -0400)
p2pool/draw.py [deleted file]
p2pool/util/vector.py [deleted file]
p2pool/web.py

diff --git a/p2pool/draw.py b/p2pool/draw.py
deleted file mode 100644 (file)
index f4cf1ba..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-import pygame
-import time
-import hashlib
-import math
-import StringIO
-from PIL import Image
-
-from p2pool.util.vector import v
-from p2pool.bitcoin import data as bitcoin_data
-
-@apply
-class color(object):
-    def __getattr__(self, name):
-        res = pygame.Color(name)
-        setattr(self, name, res)
-        return res
-
-def get_uniform(bound, *data):
-    x = int(hashlib.sha256(repr(data)).hexdigest(), 16)
-    return x % bound
-
-def get_pos(share, t, d):
-    x = 5 + get_uniform(400 - 10, share.hash, "pos")
-    y = d.get_height() - (t - share.time_seen)*10
-    if y < -10000: y = -10000
-    if y > 10000: y = 10000
-    return v(x, y)
-
-def get_color(data):
-    return [get_uniform(256, data, x) for x in "rgb"]
-
-def perp_and_normalize_to((dx, dy), d):
-    m = math.sqrt(dx**2 + dy**2)
-    return v(-dy/m*d, dx/m*d)
-
-def go(share, tracker, t, d):
-    #c = color.green if share.peer is None else color.red
-    c = get_color(share.new_script)
-    pos = get_pos(share, t, d)
-    pygame.draw.circle(d, c, pos.rounded, 5)
-    if share.previous_hash in tracker.shares:
-        previous_share = tracker.shares[share.previous_hash]
-        previous_pos = get_pos(previous_share, t, d)
-        vec_to_previous = previous_pos - pos
-        if vec_to_previous.mag() > 1:
-            pygame.draw.polygon(d, c, [
-                (pos + perp_and_normalize_to(vec_to_previous, 5)).rounded,
-                (pos + perp_and_normalize_to(vec_to_previous, -5)).rounded,
-                previous_pos.rounded,
-            ])
-    if share.peer is None:
-        pygame.draw.circle(d, c, pos.rounded, 10, 2)
-    for child_hash in tracker.reverse_shares.get(share.hash, set()):
-        go(tracker.shares[child_hash], tracker, t, d)
-    d.blit(f.render(bitcoin_data.script2_to_human(share.new_script, tracker.net.PARENT), True, (255, 255, 255)), pos)
-
-pygame.font.init()
-f = pygame.font.SysFont("Monospace", 16)
-
-def get(tracker, best):
-    d = pygame.Surface((600, 600), 32)
-    if tracker.get_height(best) >= 100:
-        t = time.time()
-        start = tracker.get_nth_parent_hash(best, 100)
-        d.fill((0, 0, 0))
-        go(tracker.shares[start], tracker, t, d)
-    f = StringIO.StringIO()
-    Image.fromstring("RGB", d.get_size(), pygame.image.tostring(d, "RGB")).save(f, "png")
-    return f.getvalue()
diff --git a/p2pool/util/vector.py b/p2pool/util/vector.py
deleted file mode 100644 (file)
index 20c69f6..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-from __future__ import absolute_import, division
-
-import math
-
-class Vector(tuple):
-    for name, operator in [("neg", "-%s"), ("pos", "+%s"), ("abs", "abs(%s)")]:
-        exec("def __%s__(self): return Vector(%s for x in self)" % (name, operator % "x"))
-    
-    for name, operator in [
-        ("add", "%s+%s"), ("sub", "%s-%s"), ("mul", "%s*%s"), ("truediv", "%s/%s"), ("floordiv", "%s//%s"),
-        ("call", "%s(%s)"),
-    ]:
-        exec("""def __%s__(self, other):
-        try:
-            return %s(%s for x, y in zip(self, other))
-        except:
-            return Vector(%s for x in self)""" % (name, "sum" if name == "mul" else "Vector", operator % ("x", "y"), operator % ("x", "other")))
-        exec("""def __r%s__(self, other):
-        try:
-            return %s(%s for x, y in zip(self, other))
-        except:
-            return Vector(%s for x in self)""" % (name, "sum" if name == "mul" else "Vector", operator % ("y", "x"), operator % ("other", "x")))
-    
-    def __mod__((x, y, z), (X, Y, Z)):
-        return Vector([y*Z-z*Y, z*X-x*Z, x*Y-y*X])
-    
-    def __rmod__((X, Y, Z), (x, y, z)):
-        return Vector([y*Z-z*Y, z*X-x*Z, x*Y-y*X])
-    
-    def __repr__(self):
-        return 'v%s' % tuple.__repr__(self)
-    
-    def __getitem__(self, item):
-        if isinstance(item, slice):
-            return Vector(tuple.__getitem__(self, item))
-        else:
-            return tuple.__getitem__(self, item)
-    
-    def __getslice__(self, i, j):
-        return self.__getitem__(slice(i, j))
-    
-    def mag(self):
-        return math.sqrt(self*self)
-    
-    def unit(self):
-        m = self.mag()
-        if m == 0:
-            return self
-        return (1/m)*self
-    
-    @property
-    def rounded(self):
-        return Vector(int(x + .5) for x in self)
-    
-    @property
-    def truncated(self):
-        return Vector(int(x) for x in self)
-
-def v(*args):
-    return Vector(args)
index d87119e..9bc6675 100644 (file)
@@ -186,12 +186,6 @@ def get_web_root(tracker, current_work, current_work2, get_current_txouts, datad
     web_root.putChild('recent_blocks', WebInterface(lambda: recent_blocks))
     web_root.putChild('uptime', WebInterface(lambda: time.time() - start_time))
     
-    try:
-        from . import draw
-        web_root.putChild('chain_img', WebInterface(lambda: draw.get(tracker, current_work.value['best_share_hash']), 'image/png'))
-    except ImportError:
-        print "Install Pygame and PIL to enable visualizations! Visualizations disabled."
-    
     new_root = resource.Resource()
     web_root.putChild('web', new_root)