修改项目配置信息 @author baozi <202-02-22> @param: get ( dict ): 用户请求信息 包含name,data @return
(self, get)
| 1735 | |
| 1736 | |
| 1737 | def ChangeProjectConf(self, get): |
| 1738 | """修改项目配置信息 |
| 1739 | @author baozi <202-02-22> |
| 1740 | @param: |
| 1741 | get ( dict ): 用户请求信息 包含name,data |
| 1742 | @return |
| 1743 | """ |
| 1744 | conf = self._get_project_conf(get.name.strip()) |
| 1745 | if not conf: |
| 1746 | return public.returnMsg("没有该项目") |
| 1747 | if self.prep_status(conf) == "running": |
| 1748 | return public.returnMsg(False, "项目环境安装制作中.....<br>请勿操作") |
| 1749 | if not os.path.exists(conf["path"]): |
| 1750 | return public.returnMsg(False, "项目文件丢失,请尝试移除本项目,重新建立") |
| 1751 | data: dict = get.data |
| 1752 | |
| 1753 | change_values = {} |
| 1754 | if "call_app" in data and data["call_app"] != conf["call_app"]: |
| 1755 | conf["call_app"] = data["call_app"] |
| 1756 | change_values["call_app"] = data["call_app"] |
| 1757 | |
| 1758 | try: |
| 1759 | if "env_list" in data and isinstance(data["env_list"], str): |
| 1760 | conf["env_list"] = json.loads(data["env_list"]) |
| 1761 | except: |
| 1762 | return public.returnMsg(False, "环境变量格式错误") |
| 1763 | |
| 1764 | if "env_list" in data and isinstance(data["env_list"], list): |
| 1765 | conf["env_list"] = data["env_list"] |
| 1766 | |
| 1767 | if "env_file" in data and isinstance(data["env_file"], str) and data["env_file"] != conf["env_file"]: |
| 1768 | conf["env_file"] = data["env_file"] |
| 1769 | |
| 1770 | # stype |
| 1771 | if "stype" in data and data["stype"] != conf["stype"]: |
| 1772 | if data["stype"] not in ("uwsgi", "gunicorn", "python", "command"): |
| 1773 | return public.returnMsg(False, "启动方式选择错误") |
| 1774 | else: |
| 1775 | self.__stop_project(conf) |
| 1776 | conf["stype"] = data["stype"] |
| 1777 | if "xsgi" in data and data["xsgi"] != conf["xsgi"]: |
| 1778 | if data["xsgi"] not in ("wsgi", "asgi"): |
| 1779 | return public.returnMsg(False, "网络协议选择错误") |
| 1780 | else: |
| 1781 | conf["xsgi"] = data["stype"] |
| 1782 | change_values["xsgi"] = data["stype"] |
| 1783 | # 检查服务器部署的可行性 |
| 1784 | msg = self.__check_feasibility(conf) |
| 1785 | if msg: return public.returnMsg(False, msg) |
| 1786 | # rfile |
| 1787 | if "rfile" in data and data["rfile"] != conf["rfile"]: |
| 1788 | if not data["rfile"].startswith(conf["path"]): |
| 1789 | return public.returnMsg(False, "启动文件不在项目目录下") |
| 1790 | change_values["rfile"] = data["rfile"] |
| 1791 | conf["rfile"] = data["rfile"] |
| 1792 | # parm |
| 1793 | if conf["stype"] == "python": |
| 1794 | conf["parm"] = data["parm"] if "parm" in data else conf["parm"] |
nothing calls this directly
no test coverage detected