Skip to content

Instantly share code, notes, and snippets.

@guerbai
Created February 1, 2020 10:57
Show Gist options
  • Save guerbai/3a668dbb90afba69ccf2d4b594261cf1 to your computer and use it in GitHub Desktop.
Save guerbai/3a668dbb90afba69ccf2d4b594261cf1 to your computer and use it in GitHub Desktop.
#Python
import subprocess
def progress_exist(name):
ps = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
job = subprocess.Popen(['grep', name], stdin=ps.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
ps.stdout.close()
out, err = job.communicate()
out = out.decode()
no_grep_out = 0
if len(out) > 0:
out_lines = out.split('\n')
for o in out_lines:
if 'grep' not in o and len(o) > 0:
no_grep_out += 1
return no_grep_out > 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment