Skip to content

Instantly share code, notes, and snippets.

@dlai0001
Created November 16, 2013 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlai0001/7494459 to your computer and use it in GitHub Desktop.
Save dlai0001/7494459 to your computer and use it in GitHub Desktop.
'''
Created on Nov 15, 2013
@author: "David Lai"
'''
import shlex, subprocess
if __name__ == '__main__':
command_line = "ls"
args = shlex.split(command_line)
print args
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Success!
while True:
was_there_lines = False
lines = proc.stdout.readlines()
for line in lines:
was_there_lines = True
print line
#if "Executing: [delete session:" in line:
if "ghostdriver.log" in line:
# Kill the selenium node process, then reboot.
print "Session delete detected. Killing terminating and rebooting this node."
proc.terminate()
if len(lines) > 0:
continue
if proc.poll() is not None:
break
print "rebooting the system."
# DOSTUFF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment