Пример #1
0
 async def run_cmd_with_envvar(self, conda_env):
     self.proc = await asyncio.create_subprocess_shell(
         util.shell_join(self.run_command),
         stdout=asyncio.subprocess.PIPE,
         stderr=asyncio.subprocess.PIPE,
         executable="/bin/bash",
         cwd=self.proc_def.root,
         env=conda_env,
         start_new_session=True,
     )
     # TODO(lshamis): Handle the case where proc dies before we can query getpgid.
     self.proc_pgrp = os.getpgid(self.proc.pid)
Пример #2
0
    def _build(self, name: str, proc_def: ProcDef):
        if not self.env_nosandbox:
            self._create_env(name, proc_def)

        if self.setup_commands:
            print(f"setting up conda env for {name}")
            setup_command = "\n".join(
                [util.shell_join(cmd) for cmd in self.setup_commands]
            )
            result = subprocess.run(
                f"""
                    eval "$(conda shell.bash hook)"
                    conda activate {self._env_name(name)}
                    cd {proc_def.root}
                    {setup_command}
                """,
                shell=True,
                executable="/bin/bash",
                capture_output=not CommonFlags.verbose,
            )
            if result.returncode:
                util.fail(f"Failed to set up conda env: {result.stderr}")
Пример #3
0
 def test_basic(self):
     assert util.shell_join(["a", "b", "c"]) == "a b c"
Пример #4
0
 def test_empty(self):
     assert util.shell_join([]) == ""
Пример #5
0
 def test_noescape(self):
     assert util.shell_join(["a", util.NoEscape(";b"), "c"]) == "a ;b c"
Пример #6
0
 def test_escape(self):
     assert util.shell_join(["a", ";b", "c"]) == "a ';b' c"