diff --git a/client.py b/client.py index c3de9f9..5984c0d 100755 --- a/client.py +++ b/client.py @@ -26,15 +26,15 @@ def RandomFill(message, width, height): message[2:] = [pixel] yield ''.join(message) -def RunClient(): +def RunClient(options): """Discover the servers and start sending to the first one""" client = PixelVloedClient(True, # start as soon as we find a server - False, # show debugging output - None, # ip of the server, None for autodetect - None, # port of the server None for autodetect - None, # Screen pixels wide, None for autodetect - None # Screen pixels height, None for autodetect + options.debug, # show debugging output + options.ip, # ip of the server, None for autodetect + options.port, # port of the server None for autodetect + options.width, # Screen pixels wide, None for autodetect + options.height # Screen pixels height, None for autodetect ) message = NewMessage() #create a new message that buffers the output etc @@ -49,7 +49,19 @@ def RunClient(): if __name__ == '__main__': # if this script is called from the command line, and thus not imported # start a client and start sending messages + import optparse + parser = optparse.OptionParser() + parser.add_option('-v', action="store_true", dest="debug", default=False) + parser.add_option('-i', action="store", dest="ip", default=None) + parser.add_option('-p', action="store", dest="port", default=None, + type="int") + parser.add_option('-x', action="store", dest="width", default=None, + type="int") + parser.add_option('-y', action="store", dest="height", default=None, + type="int") + options, remainder = parser.parse_args() + try: - RunClient() + RunClient(options) except KeyboardInterrupt: print 'Closing client' diff --git a/sdlvloed.py b/sdlvloed.py index 7c2efb0..b5bbf31 100755 --- a/sdlvloed.py +++ b/sdlvloed.py @@ -16,7 +16,6 @@ from gevent import spawn, monkey monkey.patch_all() import sdl2.ext -from pygame import locals as pygamelocals import struct import time import socket diff --git a/vloed.py b/vloed.py index 8798f4e..0d4fd41 100755 --- a/vloed.py +++ b/vloed.py @@ -225,8 +225,11 @@ class PixelVloedClient(object): self.width = width self.height = height if self.debug: - print ('displaying on %(ip)s:%(port)d, %(width)d*%(height)dpx' % - self) + print ('displaying on %(ipaddress)s:%(port)d, %(width)d*%(height)dpx' % + {'ipaddress': self.ipaddress, + 'port': self.port, + 'width': self.width, + 'height': self.height}) self.sock = socket.socket(socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP