(self)
| 216 | return None |
| 217 | |
| 218 | def get_pid_by_command(self) -> Optional[int]: |
| 219 | cmd_list = self.split_command() |
| 220 | target = [] |
| 221 | for p in psutil.process_iter(["cmdline", "pid", "exe"]): |
| 222 | try: |
| 223 | real_cmd = p.cmdline() |
| 224 | if cmd_list == real_cmd: |
| 225 | target.append(p) |
| 226 | if real_cmd[2:] == cmd_list[1:] and real_cmd[0].startswith(self.env.python_path): |
| 227 | target.append(p) |
| 228 | except: |
| 229 | continue |
| 230 | |
| 231 | for p in target: |
| 232 | try: |
| 233 | if p.ppid() not in target: |
| 234 | return p.pid |
| 235 | except: |
| 236 | continue |
| 237 | return None |
| 238 | |
| 239 | def split_command(self) -> List[str]: |
| 240 | res = [] |
no test coverage detected