qiaofeng1227 2 years ago
parent
commit
0b9eae712b
2 changed files with 13 additions and 3 deletions
  1. 10 0
      appmanage/api/utils/const.py
  2. 3 3
      appmanage/api/v1/routers/apps.py

+ 10 - 0
appmanage/api/utils/const.py

@@ -1,5 +1,15 @@
 # 所有常量统一定义区
 
+# 错误代码定义
+ERROR_CLIENT_PARAM_BLANK="Client.Parameter.Blank.Error"
+ERROR_CLIENT_PARAM_BLANK="Client.Parameter.Format.Error"
+ERROR_CLIENT_PARAM_NOTEXIST="Client.Parameter.Value.NotExist.Error"
+ERROR_CLIENT_PARAM_REPEAT="Client.Parameter.Value.Repeat.Error"
+
+ERROR_SERVER_COMMAND="Server.Container.Error"
+ERROR_SERVER_SYSTEM="Server.SystemError"
+ERROR_SERVER_RESOURCE="Server.ResourceError"
+
 # 应用状态定义
 # 应用启动中 installing
 APP_STATUS_INSTALLING = "installing"

+ 3 - 3
appmanage/api/v1/routers/apps.py

@@ -8,7 +8,7 @@ import os, io, sys, platform, shutil, time, subprocess, json, datetime
 from api.model.app import App
 from api.model.response import Response
 from api.service import manage
-from api.utils import shell_execute
+from api.utils import shell_execute, const
 from api.utils.common_log import myLogger
 from api.exception.command_exception import CommandException
 
@@ -73,11 +73,11 @@ def AppInstall(request: Request, app_name: Optional[str] = Query(default=None, d
     except CommandException as ce:
         ret = {}
         ret['ResponseData']['AppID'] = app_name + "_" + customer_app_name
-        ret['Error']=manage.get_error_info("Server.Container.Error","Docker returns the original error",str(ce))
+        ret['Error']=manage.get_error_info(const.ERROR_SERVER_COMMAND,"Docker returns the original error",str(ce))
     except Exception as e:
         ret = {}
         ret['ResponseData']['AppID'] = app_name + "_" + customer_app_name
-        ret['Error']=manage.get_error_info("Server.SystemError","system original error",str(e))
+        ret['Error']=manage.get_error_info(const.ERROR_SERVER_SYSTEM,"system original error",str(e))
 
     return JSONResponse(content=ret)