Fix selection of effect
This commit is contained in:
parent
dd72459b24
commit
07cd3eb9ed
1 changed files with 7 additions and 10 deletions
17
client.py
17
client.py
|
|
@ -46,25 +46,18 @@ def RunClient(options):
|
||||||
screen = Packet(client)
|
screen = Packet(client)
|
||||||
# loop the effect until we cancel by pressing ctrl+c / exit the program
|
# loop the effect until we cancel by pressing ctrl+c / exit the program
|
||||||
|
|
||||||
# we run the effect that has been given trough the -e flag.
|
|
||||||
# This defaults to RandomFill
|
|
||||||
if options.effect:
|
|
||||||
effect = locals()[options.effect]
|
|
||||||
else:
|
|
||||||
effect = RandomFill
|
|
||||||
|
|
||||||
while screen:
|
while screen:
|
||||||
|
|
||||||
# add some pixels to the screen with our functions
|
# add some pixels to the screen with our functions
|
||||||
# the width/height are read from the client's config
|
# the width/height are read from the client's config
|
||||||
effect(screen, client.width, client.height)
|
options.effect(screen, client.width, client.height)
|
||||||
|
|
||||||
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
|
import optparse
|
||||||
parser = optparse.OptionParser()
|
parser = optparse.OptionParser()
|
||||||
parser.add_option('-v', action="store_true", dest="debug", default=False,
|
parser.add_option('-v', action="store_true", dest="debug", default=False,
|
||||||
help="Enable debugging output")
|
help="Enable debugging output")
|
||||||
parser.add_option('-i', action="store", dest="ip", default=None,
|
parser.add_option('-i', action="store", dest="ip", default=None,
|
||||||
help="Ip of the server, leave empty for auto-discovery")
|
help="Ip of the server, leave empty for auto-discovery")
|
||||||
|
|
@ -74,10 +67,14 @@ if __name__ == '__main__':
|
||||||
type="int", help="Width of the server's screen")
|
type="int", help="Width of the server's screen")
|
||||||
parser.add_option('-y', action="store", dest="height", default=None,
|
parser.add_option('-y', action="store", dest="height", default=None,
|
||||||
type="int", help="Height of the server's screen")
|
type="int", help="Height of the server's screen")
|
||||||
parser.add_option('-e', action="store", dest="effect", default=None,
|
parser.add_option('-e', action="store", dest="effect", default='RandomFill',
|
||||||
type="str", help="Which effect to run.")
|
type="str", help="Which effect to run.")
|
||||||
options, remainder = parser.parse_args()
|
options, remainder = parser.parse_args()
|
||||||
|
|
||||||
|
# we run the effect that has been given trough the -e flag.
|
||||||
|
# This defaults to RandomFill
|
||||||
|
options.effect = locals()[options.effect]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
RunClient(options)
|
RunClient(options)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue