(sh_str: str, out: TextIO, timeout=None, user=None)
| 561 | |
| 562 | @staticmethod |
| 563 | def exec_shell(sh_str: str, out: TextIO, timeout=None, user=None): |
| 564 | if user: |
| 565 | import pwd |
| 566 | res = pwd.getpwnam(user) |
| 567 | uid = res.pw_uid |
| 568 | gid = res.pw_gid |
| 569 | |
| 570 | def preexec_fn(): |
| 571 | os.setgid(gid) |
| 572 | os.setuid(uid) |
| 573 | else: |
| 574 | preexec_fn = None |
| 575 | |
| 576 | p = subprocess.Popen(sh_str, stdout=out, stderr=out, shell=True, preexec_fn=preexec_fn) |
| 577 | p.wait(timeout=timeout) |
| 578 | return |
| 579 | |
| 580 | def run_simple_prep_env(self, project_id: int, project_conf: dict) -> Tuple[bool, str]: |
| 581 | prep_pid_file = "{}/{}.pid".format(self._prep_path, project_conf["pjname"]) |
no test coverage detected