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

Method RemoveProject

class/projectModel/pythonModel.py:1492–1545  ·  view source on GitHub ↗

删除项目接口 @author baozi <202-02-22> @param: get ( dict ): 请求信息对象 @return msg : 是否删除成功

(self, get)

Source from the content-addressed store, hash-verified

1490 return self.RemoveProject(get)
1491
1492 def RemoveProject(self, get):
1493 """删除项目接口
1494 @author baozi <202-02-22>
1495 @param:
1496 get ( dict ): 请求信息对象
1497 @return msg : 是否删除成功
1498 """
1499 name = get.name.strip()
1500 project = self.get_project_find(name)
1501 if not project:
1502 return public.returnMsg(False, "没有该项目,请尝试刷新页面")
1503 conf = project["project_config"]
1504 if not conf:
1505 return public.returnMsg(False, "没有该项目,请尝试刷新页面")
1506 if self.prep_status(conf) == "running":
1507 return public.returnMsg(False, "项目环境安装制作中.....<br>请勿操作")
1508 pid = self.get_project_run_state(name)
1509 if pid:
1510 self.StopProject(get)
1511
1512 self.del_crontab(name)
1513 self.remove_redirect_by_project_name(get.name)
1514 self.clear_config(get.name)
1515 logfile = self._logs_path + "/%s.log" % conf["pjname"]
1516
1517 try:
1518 em = EnvironmentManager()
1519 python_bin = conf.get("python_bin", "")
1520 if not python_bin:
1521 python_bin_data = em.get_env_py_path(conf["vpath"])
1522 if python_bin_data:
1523 python_bin = python_bin_data.bin_path
1524 if python_bin:
1525 em.multi_remove_env(python_bin)
1526 except Exception as e:
1527 pass
1528
1529 if os.path.exists(logfile):
1530 os.remove(logfile)
1531 if os.path.exists(conf["path"] + "/uwsgi.ini"):
1532 os.remove(conf["path"] + "/uwsgi.ini")
1533 if os.path.exists(conf["path"] + "/gunicorn_conf.py"):
1534 os.remove(conf["path"] + "/gunicorn_conf.py")
1535
1536 for suffix in ("_python.sh", "_uwsgi.sh", "_gunicorn.sh", "_cmd.sh"):
1537 cmd_file = os.path.join("{}/{}{}".format(self._script_path, conf["pjname"], suffix))
1538 if os.path.exists(cmd_file):
1539 os.remove(cmd_file)
1540 from mod.base.web_conf import remove_sites_service_config
1541 remove_sites_service_config(get.name, "python_")
1542 public.M('domain').where('pid=?', (project['id'],)).delete()
1543 public.M('sites').where('name=?', (name,)).delete()
1544 public.WriteLog(self._log_name, '删除Python项目{}'.format(name))
1545 return public.returnMsg(True, "删除成功")
1546
1547 @staticmethod
1548 def _check_venv_path(v_path: str, project_id) -> bool:

Callers 1

remove_projectMethod · 0.95

Calls 15

get_project_findMethod · 0.95
prep_statusMethod · 0.95
get_project_run_stateMethod · 0.95
StopProjectMethod · 0.95
del_crontabMethod · 0.95
clear_configMethod · 0.95
get_env_py_pathMethod · 0.95
multi_remove_envMethod · 0.95
EnvironmentManagerClass · 0.90
returnMsgMethod · 0.80

Tested by

no test coverage detected