MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / exec_shell

Method exec_shell

class/projectModel/pythonModel.py:563–578  ·  view source on GitHub ↗
(sh_str: str, out: TextIO, timeout=None, user=None)

Source from the content-addressed store, hash-verified

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"])

Callers 2

simple_prep_envMethod · 0.45
install_requirementMethod · 0.45

Calls 1

waitMethod · 0.45

Tested by

no test coverage detected