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

Method shell_env

mod/project/python/serviceMod.py:69–89  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
92class PythonService(object):

Callers 1

startMethod · 0.80

Calls 4

activate_shellMethod · 0.80
formatMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected