From 8d9d03b69a6ba150774aee2c211fa7f2064374a9 Mon Sep 17 00:00:00 2001 From: CodePanter Date: Thu, 28 Apr 2016 16:46:03 +0200 Subject: [PATCH 1/5] Fixed a few typo's in the doc-strings and comments. --- client.py | 16 ++++++++-------- vloed.py | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client.py b/client.py index 6aaa5c2..8602630 100755 --- a/client.py +++ b/client.py @@ -1,7 +1,7 @@ #!/usr/bin/python """This is an udp / binary client -Inspired by the PixelFlut beamer on eth0:winter 2016 and +Inspired by the PixelFlut projector on eth0:winter 2016 and code from https://github.com/defnull/pixelflut/ """ @@ -33,20 +33,20 @@ def RunClient(): False, # show debugging output None, # ip of the server, None for autodetect None, # port of the server None for autodetect - None, # Screen pixels wide, or Autodetect - None # Screen pixels height, or Autodetect + None, # Screen pixels wide, None for autodetect + None # Screen pixels height, None for autodetect ) message = NewMessage() #create a new message that buffers the output etc - # loop the effect untill we cancel by pressing ctrl+c / exit the program + # loop the effect until we cancel by pressing ctrl+c / exit the program while True: - # create a new message and send if everytime the buffer is full + # create a new message and send it every time the buffer is full # the width/height are read from the client's config for packet in RandomFill(message, client.width, client.height): - # send the message we just filled with random pixelfs + # send the message we just filled with random pixels client.SendPacket(packet) if __name__ == '__main__': - # if this script is called from the commandline, and thus not imported - # Start a client and start sending messages + # if this script is called from the command line, and thus not imported + # start a client and start sending messages RunClient() diff --git a/vloed.py b/vloed.py index 0e11919..1c9e74b 100755 --- a/vloed.py +++ b/vloed.py @@ -1,7 +1,7 @@ #!/usr/bin/python """This is a udp / binary version of PixelFlut -Inspired by the PixelFlut beamer on eth0:winter 2016 and +Inspired by the PixelFlut projector on eth0:winter 2016 and code from https://github.com/defnull/pixelflut/ """ @@ -97,7 +97,7 @@ class Canvas(object): def Draw(self): """Draws pixels specified in the received packages in the queue""" if self.queue.empty(): - # indicat that nothing was done, and w can skip flipping the screen + # indicate that nothing was done, and we can skip flipping the screen return False #access the pixel array and lock it self.pixels = pygame.surfarray.pixels2d(self.screen) @@ -220,7 +220,7 @@ class PixelVloedClient(object): @staticmethod def DiscoverServers(returnfirst=False, timeout=5): - """Discover servers that send out the pixelfvloed preample""" + """Discover servers that send out the pixelvloed preample""" discoverysock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) discoverysock.bind(('', DISCOVER_PORT)) starttime = time.time() From b638c794614c92f784fa88022c5b10abcf355625 Mon Sep 17 00:00:00 2001 From: CodePanter Date: Thu, 28 Apr 2016 16:57:10 +0200 Subject: [PATCH 2/5] Prevented the 'SendDiscoveryPacket' from crashing. --- vloed.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/vloed.py b/vloed.py index 1c9e74b..8f77f71 100755 --- a/vloed.py +++ b/vloed.py @@ -135,13 +135,17 @@ class Canvas(object): def SendDiscoveryPacket(self): """Lets send out our ip/port/resolution to any listening clients""" - self.broadcastsocket.sendto( - '%s:%f %s:%d %d*%d' % (PROTOCOL_PREAMBLE, PROTOCOL_VERSION, - UDP_IP, UDP_PORT, - self.width, self.height), - ('', DISCOVER_PORT)) - if self.debug: - print 'sending discovery packet' + try: + self.broadcastsocket.sendto( + '%s:%f %s:%d %d*%d' % (PROTOCOL_PREAMBLE, PROTOCOL_VERSION, + UDP_IP, UDP_PORT, + self.width, self.height), + ('', DISCOVER_PORT)) + if self.debug: + print 'sending discovery packet' + except Exception as error: + if self.debug: + print error def __del__(self): """Clean up any sockets we created""" From f22e3a2a56b4cabf940dc63f00a2283141eb81e6 Mon Sep 17 00:00:00 2001 From: CodePanter Date: Thu, 28 Apr 2016 20:24:37 +0200 Subject: [PATCH 3/5] Pixels can no longer be added to a MaxSizeList if the list is full. --- client.py | 2 +- vloed.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client.py b/client.py index 8602630..61085f4 100755 --- a/client.py +++ b/client.py @@ -23,7 +23,7 @@ def RandomFill(message, width, height): message.append(pixel) except IndexError: yield ''.join(message) - message[2:] = [] + message[2:] = [pixel] yield ''.join(message) def RunClient(): diff --git a/vloed.py b/vloed.py index 8f77f71..c3e215e 100755 --- a/vloed.py +++ b/vloed.py @@ -290,9 +290,9 @@ class MaxSizeList(list): def append(self, item): """Appends an item to the list""" - super(MaxSizeList, self).append(item) if self.__len__() == self.maxsize: raise IndexError('max size reached') + super(MaxSizeList, self).append(item) def RunServer(): """Runs a pixelvloed server""" From 143debb5f656ffd8054e978034ef08451ed528d3 Mon Sep 17 00:00:00 2001 From: CodePanter Date: Thu, 28 Apr 2016 20:26:21 +0200 Subject: [PATCH 4/5] Imported 'MAX_PIXELS' and replaced a hard coded pixel maximum. --- client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client.py b/client.py index 61085f4..4bfcd66 100755 --- a/client.py +++ b/client.py @@ -9,11 +9,11 @@ __version__ = 0.3 __author__ = "Jan Klopper " import random -from vloed import PixelVloedClient, NewMessage, RGBPixel +from vloed import PixelVloedClient, NewMessage, RGBPixel, MAX_PIXELS def RandomFill(message, width, height): """Generates a random number of pixels with a random color""" - for pixel in xrange(0, random.randint(10, 140)): + for pixel in xrange(0, random.randint(10, MAX_PIXELS)): pixel = RGBPixel(random.randint(0, width), random.randint(0, height), random.randint(0, 255), From a833d43ee0aa5462d1d70b0e064cabe3a556375a Mon Sep 17 00:00:00 2001 From: CodePanter Date: Thu, 28 Apr 2016 20:28:28 +0200 Subject: [PATCH 5/5] A client's port will be 5005 when specifying an ip address and no port. --- vloed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vloed.py b/vloed.py index c3e215e..26e2ccd 100755 --- a/vloed.py +++ b/vloed.py @@ -198,7 +198,7 @@ class PixelVloedClient(object): servers[0]) else: self.ipaddress = ip - self.port = port + self.port = port if port else UDP_IP self.width = width self.height = height if self.debug: