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

Method SetupPackage

class/plugin_deployment.py:774–830  ·  view source on GitHub ↗
(self, get)

Source from the content-addressed store, hash-verified

772 # param string site_name 网站名称
773 # param string php_version PHP版本
774 def SetupPackage(self, get):
775 param_list = ['dname', 'site_name']
776 for param in param_list:
777 if not hasattr(get, param):
778 return public.returnMsg(False, '缺少参数{}'.format(param))
779
780 name = get.dname.strip()
781 site_name = get.site_name.strip()
782 project_type = get.get('project_type', 'php').strip()
783
784 # 取基础信息
785 if project_type == "java":
786 project_name = get.project_name.strip()
787 find = public.M('sites').where('name=?', (project_name,)).field('id,path,name').find()
788 else:
789 find = public.M('sites').where('name=?', (site_name,)).field('id,path,name').find()
790
791 if 'path' not in find:
792 find = self.solve_chinese_domain(site_name)
793 if find is None:
794 return public.returnMsg(False, '网站不存在!')
795 path = "/www/wwwroot/{}".format(site_name) if project_type == "java" else find['path']
796
797 if path.replace('//', '/') == '/': return public.returnMsg(False, '危险的网站根目录!')
798
799 # 获取包信息
800 packinfo = self.GetPackageInfo(name)
801 id = packinfo['id']
802 if not packinfo: return public.returnMsg(False, '指定软件包不存在!')
803
804 public.writeFile(self.logPath, "")
805
806 result = {
807 "admin_username": "",
808 "admin_password": "",
809 "success_url": "",
810 }
811 if project_type == "php" or project_type == "php_async":
812 php_result = self.__setup_php_environment(get, name, packinfo, path, find)
813 # 更新 result 字典
814 if isinstance(php_result, dict):
815 # 只更新特定的键
816 for key in ["admin_username", "admin_password", "success_url"]:
817 if key in php_result:
818 result[key] = php_result[key]
819 elif project_type == "java":
820 java_result = self.__setup_java_environment(get, path)
821 # 更新 result 字典
822 if isinstance(java_result, dict):
823 # 只更新特定的键
824 for key in ["admin_username", "admin_password", "success_url"]:
825 if key in java_result:
826 result[key] = java_result[key]
827 time.sleep(1)
828 self.WriteLogs('Success:部署【{}】成功...'.format(name))
829 if id: self.depTotal(id)
830 return public.returnMsg(True, result)
831

Callers

nothing calls this directly

Calls 15

solve_chinese_domainMethod · 0.95
GetPackageInfoMethod · 0.95
WriteLogsMethod · 0.95
depTotalMethod · 0.95
returnMsgMethod · 0.80
writeFileMethod · 0.80
formatMethod · 0.45
getMethod · 0.45
findMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected