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

Method CreateProject

class/projectModel/pythonModel.py:796–843  ·  view source on GitHub ↗

创建Python项目 @author baozi <202-02-22> @param: get ( dict ): 请求信息 @return test : 创建情况

(self, get)

Source from the content-addressed store, hash-verified

794 }
795
796 def CreateProject(self, get):
797 """创建Python项目
798 @author baozi <202-02-22>
799 @param:
800 get ( dict ): 请求信息
801 @return test : 创建情况
802 """
803 # 检查输入参数
804 flag, values = self.__check_args(get)
805 if not flag:
806 return values
807
808 public.set_module_logs("create_python_project", "create")
809 # 检查服务器部署的可行性
810 msg = self.__check_feasibility(values)
811 if msg:
812 return public.returnMsg(False, msg)
813
814 # 默认不开启映射,不绑定外网
815 values["domains"], values["bind_extranet"] = [], 0
816 # 默认进程数与线程数
817 values["processes"], values["threads"] = 4, 2
818 # 默认日志等级info
819 values["loglevel"] = "info"
820 # 默认uwsgi使用http
821 values['is_http'] = "is_http"
822
823 p_data = {
824 "name": values["pjname"],
825 "path": values["path"],
826 "ps": values["pjname"],
827 "status": 1,
828 'type_id': 0,
829 "project_type": "Python",
830 "addtime": public.getDate(),
831 "project_config": json.dumps(values)
832 }
833 res = public.M("sites").insert(p_data)
834 if isinstance(res, str) and res.startswith("error"):
835 return public.returnMsg(False, "数据库记录失败,请检查面板数据库状态")
836
837 self.run_simple_prep_env(res, values)
838 time.sleep(0.5)
839 # 返回信息
840 public.WriteLog(self._log_name, "添加Python项目{}".format(values["pjname"]))
841 flag, tip = self._release_firewall(get)
842 tip = "" if flag else "<br>" + tip
843 return public.returnMsg(True, "项目添加成功" + tip)
844
845 def __prepare_start_conf(self, values, force=False, pyenv: Optional[PythonEnvironment]=None):
846 """准备启动的配置文件,python运行不需要,uwsgi和gunicorn需要

Callers

nothing calls this directly

Calls 9

__check_argsMethod · 0.95
__check_feasibilityMethod · 0.95
run_simple_prep_envMethod · 0.95
returnMsgMethod · 0.80
_release_firewallMethod · 0.80
dumpsMethod · 0.45
insertMethod · 0.45
MMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected