def main(args): while True: body = getEmail() if body != "": coordsFile = open(os.path.dirname(__file__) + "/coords.json") coordMap = json.loads(coordsFile.read()) coordsFile.close() culprit = parseEmail(body) if coordMap[culprit] is not None: print "firing on " + culprit coordinates = coordMap[culprit] argStr = "led 1 " + coordMap[culprit] + " fire 1 led 0 reset" args = argStr.split() args.insert(0, "retaliation.py") try: print "retaliation.py " + argStr retaliation.main(args) except: print "Something went wrong in retaliation.py" time.sleep(5)
import pygame, sys import retaliation pygame.init() BLACK = (0,0,0) WIDTH = 50 HEIGHT = 50 windowSurface = pygame.display.set_mode((WIDTH, HEIGHT), 0, 32) windowSurface.fill(BLACK) while True: for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_RIGHT: print "You pressed right" retaliation.main(["retaliation.py", "right", "25"]) pass if event.type == "QUIT": pygame.quit() sys.exit()
def reset(): retaliation.main(['', 'reset']) return "OK"
def fire(): retaliation.main(['', 'fire']) return "OK"
def move_down(): amount = request.args["amount"] retaliation.main(['', 'down', amount]) return "OK"
def move_up(): amount = request.args["amount"] retaliation.main(['', 'up', amount]) return "OK"
def move_left(): amount = request.args["amount"] retaliation.main(['', 'left', amount]) return "OK"