Created
February 1, 2020 10:57
-
-
Save guerbai/3a668dbb90afba69ccf2d4b594261cf1 to your computer and use it in GitHub Desktop.
#Python
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
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