Last active
February 24, 2017 05:10
-
-
Save takahub1/6596bd0fe9131430cba45d11af975292 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import socket | |
import subprocess #for unix command | |
import time #for sleep | |
import random #for random number | |
def main(): | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind(("192.168.10.103", 51007)) # 指定したホスト(IP)とポートをソケットに設定 | |
print "waiting for connection..." | |
s.listen(1) # 1つの接続要求を待つ | |
soc, addr = s.accept() # 要求が来るまでブロック | |
print("Conneted by"+str(addr)) #サーバ側の合図 | |
while (1): | |
if raw_input() == "q": # qが押されたら終了 | |
soc.close() | |
break | |
subprocess.call('make', shell=True) #update image | |
time.sleep(1) | |
soc.send("1") | |
time.sleep(1) | |
soc.send(str(random.randint(3,4))) | |
time.sleep(1) | |
soc.send(str(random.randint(3,4))) | |
# soc.send("4") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment