(self)
| 67 | |
| 68 | # 组合环境变量,用于启动服务 |
| 69 | def shell_env(self) -> str: |
| 70 | if self._env_cache is not None: |
| 71 | return self._env_cache |
| 72 | |
| 73 | # cd 到指定路径, 加载环境变量, 加载环境变量文件, 设置Python环境到首位 |
| 74 | res_env_list = ["cd {}".format(self.project_path)] |
| 75 | if isinstance(self.env_list, list): |
| 76 | for i in self.env_list: |
| 77 | if not isinstance(i, dict): |
| 78 | continue |
| 79 | if 'k' in i and 'v' in i: |
| 80 | res_env_list.append("export {}={}".format(i['k'], i['v'])) |
| 81 | |
| 82 | if self.env_file and os.path.isfile(self.env_file): |
| 83 | res_env_list.append("source {}".format(self.env_file)) |
| 84 | |
| 85 | res_env_list.append(self.pyenv.activate_shell()) |
| 86 | |
| 87 | self._env_cache = "\n".join(res_env_list) |
| 88 | |
| 89 | return self._env_cache |
| 90 | |
| 91 | |
| 92 | class PythonService(object): |
no test coverage detected