python - Code not running after os.system call -


in code

while 1: try:     #print "try reading socket"     os.system("echo 1 >/sys/class/leds/led0/brightness")      data, wherefrom = s.recvfrom(1500, 0) # data 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 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])))      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() 

the code after

os.system('sudo python /home/pi/simplesi_scratch_handler/scratch_gpio_handler2.py '+ str(repr(wherefrom[0]))) 

doesn't seem run (the code blinks led , doesn't happen - if put blink code befoer os.system call works)

can python launch new terminal/shell , run 2nd python prog in that?

regards

simon

modify sudoers file (with visudo command) add line

myusername   all=(all:all) nopasswd:/home/pi/simplesi_scratch_handler/scratch_gpio_handler2.py 

where "myusername" user name intend run program as

you mentioned run system program in new shell?

os.system('sudo python /home/pi/simplesi_scratch_handler/scratch_gpio_handler2.py '+ str(repr(wherefrom[0])) + " &") 

runs program in such way shell starts not block process starts it.

hope helps


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -