Is the provided process name is currently running?
(process)
| 40 | |
| 41 | |
| 42 | def is_running(process): |
| 43 | """ |
| 44 | Is the provided process name is currently running? |
| 45 | """ |
| 46 | proc_list = subprocess.Popen(["pgrep", "-f", process], stdout=subprocess.PIPE) |
| 47 | for proc in proc_list.stdout: |
| 48 | if proc.decode("utf-8").rstrip() != str(os.getpid()) and proc.decode( |
| 49 | "utf-8" |
| 50 | ).rstrip() != str(os.getppid()): |
| 51 | return True |
| 52 | return False |
| 53 | |
| 54 | |
| 55 | def download_file(s, url, data_dir): |