在这段代码中
while 1:
try:
#print "try reading socket"
os.system("echo 1 >/sys/class/leds/led0/brightness")
data, wherefrom = s.recvfrom(1500, 0) # get the data from the socket
except (KeyboardInterrupt, SystemExit):
#print "reraise error"
raise
except timeout:
print "No data received: socket timeout"
#print sys.exc_info()[0]
break
except:
print "Unknown error occured with receiving data"
break
print (data + " " + repr(wherefrom[0]))
if (data.find("Start SID" + myserial[-4:]) != -1):
os.system('sudo python /home/pi/simplesi_scratch_handler/scratch_gpio_handler2.py '+ str(repr(wherefrom[0])))
for i in range (0,20):
os.system("echo 0 >/sys/class/leds/led0/brightness")
time.sleep(0.5)
os.system("echo 1 >/sys/class/leds/led0/brightness")
time.sleep(0.5)
break
os.system("echo mmc0 >/sys/class/leds/led0/trigger")
s.close()
sys.exit()
之后的代码
os.system('sudo python /home/pi/simplesi_scratch_handler/scratch_gpio_handler2.py '+ str(repr(wherefrom[0])))
似乎没有运行(代码使 LED 闪烁,这不会发生 - 如果我将闪烁代码放在 os.system 调用之前,那么它可以工作)
我可以让 python 启动一个新的终端/shell 并在其中运行我的第二个 python prog 吗?
问候
西蒙