def hear(phrase): print "heard:" + phrase for a in phrase: if a == "\r" or a == "\n": pass # strip it else: if GPIO.input(SWITCH): network.say("1") else: network.say("0")
def heard(phrase): global score global guessed_number print("them:" + phrase) if phrase == "higher": guessed_number=guessed_number*2 #double it! elif phrase == "lower": guessed_number=guessed_number-1 #decrement it. elif phrase == "CORRECT!!!": score = 1 if score == 0 and network.isConnected(): print("me:" + str(guessed_number)) network.say(str(guessed_number))
def heard(phrase): print("them:" + phrase) if phrase == "hello": network.say("hello, how are you today?") elif phrase == "bye": network.say("Are you going already?") elif phrase == "help": network.say("What can I do to help?") elif phrase == "advice": network.say("Never wear cufflinks with short sleeved shirts")
def heard(phrase): global score print("them:" + phrase) guessed_number = int(phrase) #time.sleep(1) #pause here to make the Pi seem human if network.isConnected(): if imagined_number > guessed_number: network.say("higher") elif imagined_number == guessed_number: network.say("CORRECT!!!") score = 1 else: network.say("lower")
# client.py (c) 2013 @whaleygeek # # A demo client that pokes "hello" at a server once per second import network import time network.call("localhost") while network.isConnected(): print("sending") network.say("hello") time.sleep(1)
timeperchar = timee/num #print(timeperchar) sys.stdout.write( '%s' % c ) sys.stdout.flush() time.sleep(timeperchar) sys.stdout.write("\n") sys.stdout.flush() time.sleep(0.3) os.system("clear") pygame.mixer.music.play() network.say("0") lyric("This was a triumph.",4) #time.sleep(4) lyric("I'm making a note here:",2) #time.sleep(2) lyric("HUGE SUCCESS.",3) #time.sleep(3) lyric("It's hard to overstate ",2) #time.sleep(2) lyric("my satisfaction.",5) #time.sleep(5) network.say("1") lyric("Aperture Science ",4) #time.sleep(4) lyric("We do what we must",2.2) #time.sleep(2.2)
print(displayname[site]) deldata(outer_id) adddata(outer_id, displayname[site], lockright) if __name__ == '__main__': if len(sys.argv) != 2: print("Server Mode") else: print("Client Mode") def heard(phrase): print("Receive:" + phrase) print(phrase.split()) if phrase.split()[0] == 'doing': if phrase.split()[1] == 'add': sys.exit(0) if (len(sys.argv) >= 2): network.call(sys.argv[1], whenHearCall=heard) else: network.wait(whenHearCall=heard) while network.isConnected(): phrase = raw_input() # python2 #phrase = input() print("Send:" + phrase) network.say(phrase)
def heard(phrase): if GPIO.input(SWITCH): network.say("1") else: network.say("0")
if (len(sys.argv) < 2): sys.exit() score=0 imagined_number=int(sys.argv[1]) def heard(phrase): global score print("them:" + phrase) guessed_number = int(phrase) #time.sleep(1) #pause here to make the Pi seem human if network.isConnected(): if imagined_number > guessed_number: network.say("higher") elif imagined_number == guessed_number: network.say("CORRECT!!!") score = 1 else: network.say("lower") network.wait(whenHearCall=heard) #wait for quiz taker to connect if network.isConnected(): network.say("Guess a number!") while score == 0 and network.isConnected(): time.sleep(3)
if a == "\r" or a == "\n": pass # skip it elif a == "0": GPIO.output(LED, False) else: GPIO.output(LED, True) gotResponse = True while True: while True: try: print "connecting to switch server" network.call(SERVER_IP, whenHearCall=heard) break except: print "refused" time.sleep(1) print "connected" while network.isConnected(): gotResponse = False print "polling" network.say("?") while network.isConnected() and not gotResponse: print "waiting" time.sleep(1) print "connection closed"
def heard(phrase): if (GPIO.input(SWITCH)): network.say("1") else: network.say("0")
# A simple internet chat client and server. (c) 2013 @whaleygeek import network import sys def heard(phrase): print("them:" + phrase) print("MyChat internet chat program") if (len(sys.argv) >= 2): network.call(sys.argv[1], whenHearCall=heard) else: network.wait(whenHearCall=heard) print("Connected!") network.say("Welcome to MyChat - please be nice!") while network.isConnected(): #phrase = raw_input() #python2 phrase = input() # python3 print("me:" + phrase) network.say(phrase)
pygame.display.flip() forward = 0 if keystate[pygame.K_DOWN]: pygame.draw.rect(screen, raspberrygreen, (374,350,128,128), 0) pygame.display.flip() backwards = 1 else: pygame.draw.rect(screen, raspberryred, (374,350,128,128), 0) pygame.display.flip() backwards = 0 #and now process the network code, left and right are first, forwards is second and then backwards is last. if (left == 1 and lefton == 0): network.say("l") lefton = 1 elif (right == 1 and righton == 0): network.say("r") righton = 1 elif (forward == 1 and forwardon == 0): network.say("f") forwardon = 1 elif (backwards == 1 and backwardson == 0): network.say("b") backwardson = 1 if(lefton ==1): if(left == 0): network.say("ls") lefton = 0
def send(msg): trace("sending:" + str(msg)) network.say(msg)
def handleBody(line): global network network.say("HTTP/1.0 200 OK") # response network.say("") # end of response headers(none) network.say("<html><body><H1>Hello Web Server</H1></body></html>")
for a in phrase: if a == "\r" or a == "\n": pass # skip it elif a == "0": GPIO.output(LED, False) else: GPIO.output(LED, True) gotResponse = True while True: while True: try: print "connecting to switch server" network.call(SERVER_IP, whenHearCall=heard) break except: print "refused" time.sleep(1) print "connected" while network.isConnected(): gotResponse = False print "polling" network.say("?") while network.isConnected() and not gotResponse: print "waiting" time.sleep(1) print "connection closed"
def do_work(data): # "x y" global task_num task_num += 1 print(f"doing work: |{task_num} {mode}| {data}") time.sleep(3) # pretend to do work network.say("newx newy")
import network tree_ip = "10.83.3.160" network.call(tree_ip) for X in range(1, 4): message = (X, 255, 255, 255) message = str(message) network.say(message)
$$ $$$7 $$$$ $$D $$$$$$$7 $$$$$$$$ $ $$$$$$$$$ $$$$$$$$$ $$ $$$ 7$$$$$$$$$ $$$$$$$$$$ 7$$ $$$N 7$$$$$$$$7 $$$$$$$$$7 $$$$ $$$$ $$$$$$$$$ 7$$$$$$7 7$$$ $$$ 8$$$$$$ D$$$$7 $$$ 7$ 7$$$$$$ $$ 7$$ 7$$$$$$$$ $$$$ $$$$$7 $$$$$$$$$$$ D7$$$$$ $$$$$$$ $$$$$$$$$$7 $$$$$$$$ $$$$$$$ $$$$$$$$$ $$$$$$7 8$$$$$$ 7$$$$$7 7$$$$$$N $$$$$ $$$$7 $$$$$$$8 $$$$$$$$$$$ $$$$$$$ """ if (len(sys.argv) >= 2): network.call(sys.argv[1], whenHearCall=heard) else: network.wait(whenHearCall=heard) while network.isConnected(): phrase = raw_input() print "me:" + phrase network.say(phrase)
pass # ignore header def handleBody(data): print(data) def heard(msg): global state if (state == 0): # response handleResponse(msg) state = 1 elif (state == 1): # headers if (len(msg.strip()) != 0): # not end of headers handleHeader(msg) else: # end of headers state = 2 elif (state == 2): # body handleBody(msg) # main program starts here network.call("localhost", port=port, whenHearCall=heard) network.say("GET " + url + " " + proto_ver) network.say("") network.say("") while network.isConnected(): time.sleep(1)
def send(self, msg): network.say(msg);
def send(msg): trace("outgoing:%s" % msg) if network.isConnected(): network.say(msg) else: stop_status_reports()