from broadcaster import Broadcaster
from light_strand import LightStrand
from server import Server
import Queue
import time

command_queue = Queue.Queue()
strands = LightStrand.connect_all_strands()

#start the server
server = Server(command_queue)
server.start()

#start the broadcaster
broadcaster = Broadcaster(strands, command_queue)
broadcaster.start()

while True:
    try:
        time.sleep(1)
    except (KeyboardInterrupt, SystemExit):
        server.stop()
        broadcaster.stop()
        print "Exiting..."
        break


@@ -92,16 +92,57 @@
  Server%0A
+from program_runner import ProgramRunner%0A
 import Q
@@ -158,16 +158,33 @@
 rt time%0A
+import binascii%0A%0A
 %0Acommand
@@ -414,50 +414,895 @@
 ()%0A%0A
-while True:%0A    try:%0A        time.sleep(1)
+def candy_cane():%0A    for i in range(35):%0A        color = %220F0F0F%22%0A        if i %25 2:%0A            color = %2200000F%22%0A%0A        command_string = %22FF06%7B:02X%7DFE%7B%7D000000%22.format(i , color)%0A        command = binascii.unhexlify(command_string)%0A        command_queue.put(command)%0A%0A    time.sleep(.5)%0A%0A    for i in range(35):%0A        color = %2200000F%22%0A        if i %25 2:%0A            color = %220F0F0F%22%0A%0A        command_string = %22FF06%7B:02X%7DFE%7B%7D000000%22.format(i , color)%0A        command = binascii.unhexlify(command_string)%0A        command_queue.put(command)%0A%0A    time.sleep(.5)%0A%0Aprogram = None%0Awhile True:%0A    try:%0A        selection=raw_input(%22Connect Mobile or Enter Option:%22)%0A        if program:%0A            program.stop()%0A        if selection =='1':%0A            program = ProgramRunner(candy_cane).start%0A        elif selection =='s':%0A            pass%0A        elif selection =='e':%0A            exit(0)%0A
 %0A   

add candy_cane