Add cli options to the client class, clean up the SDL version a bit
This commit is contained in:
parent
4e22d0187e
commit
d2f58a6640
3 changed files with 24 additions and 10 deletions
26
client.py
26
client.py
|
|
@ -26,15 +26,15 @@ def RandomFill(message, width, height):
|
||||||
message[2:] = [pixel]
|
message[2:] = [pixel]
|
||||||
yield ''.join(message)
|
yield ''.join(message)
|
||||||
|
|
||||||
def RunClient():
|
def RunClient(options):
|
||||||
"""Discover the servers and start sending to the first one"""
|
"""Discover the servers and start sending to the first one"""
|
||||||
|
|
||||||
client = PixelVloedClient(True, # start as soon as we find a server
|
client = PixelVloedClient(True, # start as soon as we find a server
|
||||||
False, # show debugging output
|
options.debug, # show debugging output
|
||||||
None, # ip of the server, None for autodetect
|
options.ip, # ip of the server, None for autodetect
|
||||||
None, # port of the server None for autodetect
|
options.port, # port of the server None for autodetect
|
||||||
None, # Screen pixels wide, None for autodetect
|
options.width, # Screen pixels wide, None for autodetect
|
||||||
None # Screen pixels height, None for autodetect
|
options.height # Screen pixels height, None for autodetect
|
||||||
)
|
)
|
||||||
message = NewMessage() #create a new message that buffers the output etc
|
message = NewMessage() #create a new message that buffers the output etc
|
||||||
|
|
||||||
|
|
@ -49,7 +49,19 @@ def RunClient():
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# if this script is called from the command line, and thus not imported
|
# if this script is called from the command line, and thus not imported
|
||||||
# start a client and start sending messages
|
# 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:
|
try:
|
||||||
RunClient()
|
RunClient(options)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print 'Closing client'
|
print 'Closing client'
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ from gevent import spawn, monkey
|
||||||
monkey.patch_all()
|
monkey.patch_all()
|
||||||
|
|
||||||
import sdl2.ext
|
import sdl2.ext
|
||||||
from pygame import locals as pygamelocals
|
|
||||||
import struct
|
import struct
|
||||||
import time
|
import time
|
||||||
import socket
|
import socket
|
||||||
|
|
|
||||||
7
vloed.py
7
vloed.py
|
|
@ -225,8 +225,11 @@ class PixelVloedClient(object):
|
||||||
self.width = width
|
self.width = width
|
||||||
self.height = height
|
self.height = height
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print ('displaying on %(ip)s:%(port)d, %(width)d*%(height)dpx' %
|
print ('displaying on %(ipaddress)s:%(port)d, %(width)d*%(height)dpx' %
|
||||||
self)
|
{'ipaddress': self.ipaddress,
|
||||||
|
'port': self.port,
|
||||||
|
'width': self.width,
|
||||||
|
'height': self.height})
|
||||||
self.sock = socket.socket(socket.AF_INET, # Internet
|
self.sock = socket.socket(socket.AF_INET, # Internet
|
||||||
socket.SOCK_DGRAM) # UDP
|
socket.SOCK_DGRAM) # UDP
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue