|
@@ -7,33 +7,34 @@ from ssat_sdk.MenuTree3.TConfig import TConfig
|
|
|
|
|
|
from TData import CTData
|
|
|
|
|
|
-
|
|
|
g_level = ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth',
|
|
|
'Seventh', 'Eighth', 'Ninth', 'Tenth', 'Eleventh', 'Twelfth']
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
class CConfigManager(TConfig, CBaseLog):
|
|
|
def __init__(self, menuTreeDir, pathManager):
|
|
|
- self.pathManager = pathManager
|
|
|
- if self.pathManager is None:
|
|
|
+ self.__pathManager = pathManager
|
|
|
+ if self.__pathManager is None:
|
|
|
self.error("路径参数错误:None")
|
|
|
|
|
|
self.status = False
|
|
|
|
|
|
- self.uiTreeDir = menuTreeDir
|
|
|
+ self.__uiTreeDir = menuTreeDir
|
|
|
|
|
|
- if not os.path.isdir(self.uiTreeDir):
|
|
|
- self.error("%s 不是menuTree目录" % self.uiTreeDir)
|
|
|
+ if not os.path.isdir(self.__uiTreeDir):
|
|
|
+ self.error("%s 不是menuTree目录" % self.__uiTreeDir)
|
|
|
|
|
|
- if not os.path.exists(self.uiTreeDir):
|
|
|
- self.error("menuTree(%s)目录不存在" % self.uiTreeDir)
|
|
|
+ if not os.path.exists(self.__uiTreeDir):
|
|
|
+ self.error("menuTree(%s)目录不存在" % self.__uiTreeDir)
|
|
|
|
|
|
- self.configPath = os.path.join(self.uiTreeDir, "menutree.ini")
|
|
|
- if not os.path.exists(self.configPath):
|
|
|
- self.error("menutree配置文件不存在:%s" % self.configPath)
|
|
|
+ self.__configPath = os.path.join(self.__uiTreeDir, "menutree.ini")
|
|
|
+ if not os.path.exists(self.__configPath):
|
|
|
+ self.error("menutree配置文件不存在:%s" % self.__configPath)
|
|
|
self.status = True
|
|
|
|
|
|
- TConfig.__init__(self, self.configPath)
|
|
|
+ TConfig.__init__(self, self.__configPath)
|
|
|
|
|
|
|
|
|
def getSuperPassword(self):
|
|
@@ -69,11 +70,13 @@ class CConfigManager(TConfig, CBaseLog):
|
|
|
|
|
|
|
|
|
def __getICONConfig(self, optionName, is_value_sheet=False):
|
|
|
- paths = self.pathManager.get_option_paths(optionName)
|
|
|
+
|
|
|
+ def_cfg = {"icon_path": "", "dcfg": {}, "dir_path": ""}
|
|
|
+ paths = self.__pathManager.get_option_paths(optionName)
|
|
|
|
|
|
if paths.__len__() == 0:
|
|
|
- self.error("当前【%s】的路径节点空" % optionName)
|
|
|
- return False, {"icon_path": "", "dcfg": {}, "dir_path": ""}
|
|
|
+ self.error("当前【%s】的路径节点空,使用默认的配置值%s" % (optionName, def_cfg))
|
|
|
+ return False, def_cfg
|
|
|
|
|
|
|
|
|
first_parent = paths[g_level[0]]['parent']
|
|
@@ -85,34 +88,37 @@ class CConfigManager(TConfig, CBaseLog):
|
|
|
cur_level = "value"
|
|
|
|
|
|
|
|
|
- icon_path = os.path.join(self.uiTreeDir, "icon\\", cur_parent + "." + cur_level + "_" + optionName + ".png")
|
|
|
+ icon_path = os.path.join(self.__uiTreeDir, "icon\\", cur_parent + "." + cur_level + "_" + optionName + ".png")
|
|
|
|
|
|
- icon_dir_path = os.path.join(self.uiTreeDir, "icon\\" + cur_parent + "." + cur_level + "_" + optionName + ".dir.png")
|
|
|
+ icon_dir_path = os.path.join(self.__uiTreeDir,
|
|
|
+ "icon\\" + cur_parent + "." + cur_level + "_" + optionName + ".dir.png")
|
|
|
|
|
|
opc_cfg = self.get_value_dict(cur_level, cur_parent + '.' + optionName)
|
|
|
|
|
|
- last_path = icon_path
|
|
|
|
|
|
if not os.path.exists(icon_path):
|
|
|
|
|
|
- icon_path = os.path.join(self.uiTreeDir, "icon\\" + cur_parent + "." + cur_level + ".png")
|
|
|
- icon_dir_path = os.path.join(self.uiTreeDir, "icon\\" + cur_parent + "." + cur_level + ".dir.png")
|
|
|
+ self.warn("Option(%s)首配图片不存在:%s" % (optionName, icon_path))
|
|
|
+ icon_path = os.path.join(self.__uiTreeDir, "icon\\" + cur_parent + "." + cur_level + ".png")
|
|
|
+ icon_dir_path = os.path.join(self.__uiTreeDir, "icon\\" + cur_parent + "." + cur_level + ".dir.png")
|
|
|
opc_cfg = self.get_value_dict(cur_level, cur_parent)
|
|
|
- self.warn("Option(%s)首配图片不存在:%s,使用次配图:%s" % (optionName, icon_path))
|
|
|
+ self.warn("Option(%s)首配图片不存在,尝试使用次配图(%s):%s,配置%s" % (optionName, cur_parent, icon_path, opc_cfg))
|
|
|
|
|
|
if not os.path.exists(icon_path):
|
|
|
self.warn("Option(%s)次配图片不存在:%s" % (optionName, icon_path))
|
|
|
|
|
|
- icon_path = os.path.join(self.uiTreeDir, "icon\\" + first_parent + "." + cur_level + "_" + optionName +
|
|
|
+ icon_path = os.path.join(self.__uiTreeDir,
|
|
|
+ "icon\\" + first_parent + "." + cur_level + "_" + optionName +
|
|
|
".png")
|
|
|
- icon_dir_path = os.path.join(self.uiTreeDir, "icon\\" + first_parent + "." + cur_level + "_" + optionName +
|
|
|
+ icon_dir_path = os.path.join(self.__uiTreeDir,
|
|
|
+ "icon\\" + first_parent + "." + cur_level + "_" + optionName +
|
|
|
".dir.png")
|
|
|
opc_cfg = self.get_value_dict(cur_level, first_parent)
|
|
|
-
|
|
|
+ self.warn("Option(%s)次配图片不存在,尝试使用顶层配图(%s):%s,配置%s" % (optionName, first_parent, icon_path, opc_cfg))
|
|
|
|
|
|
if not os.path.exists(icon_path):
|
|
|
- self.error("%s对应的顶层菜单配图不存在%s" % (optionName, icon_path))
|
|
|
- return False, {"icon_path": "", "dcfg": {}, "dir_path": ""}
|
|
|
+ self.error("%s对应的顶层菜单配图不存在%s,使用默认配置%s" % (optionName, icon_path, def_cfg))
|
|
|
+ return False, def_cfg
|
|
|
|
|
|
|
|
|
|
|
@@ -133,7 +139,7 @@ class CConfigManager(TConfig, CBaseLog):
|
|
|
|
|
|
def getOptionOCRConfig(self, optionName):
|
|
|
ocr_dict = []
|
|
|
- paths = self.pathManager.get_option_paths(optionName)
|
|
|
+ paths = self.__pathManager.get_option_paths(optionName)
|
|
|
|
|
|
if paths.__len__() == 0:
|
|
|
self.error("当前【%s】的路径节点空" % optionName)
|
|
@@ -142,7 +148,7 @@ class CConfigManager(TConfig, CBaseLog):
|
|
|
else:
|
|
|
|
|
|
if self.status is False:
|
|
|
- self.warn("配置文件(%s)不存在,%s使用默认的ocr配置", self.configPath, optionName)
|
|
|
+ self.warn("配置文件(%s)不存在,%s使用默认的ocr配置" % (self.__configPath, optionName))
|
|
|
ocr_dict = [{"lan": "ChinesePRC+English", "type": 4}, {"lan": "ChinesePRC+English", "type": 253},
|
|
|
{"lan": "ChinesePRC+English", "type": 10001}]
|
|
|
else:
|
|
@@ -153,17 +159,17 @@ class CConfigManager(TConfig, CBaseLog):
|
|
|
cur_level = g_level[i]
|
|
|
|
|
|
if self.has_option(cur_level, optionName + '.ocr'):
|
|
|
- self.warn("%s使用自身的ocr配置", optionName)
|
|
|
+ self.warn("%s使用自身的ocr配置" % optionName)
|
|
|
ocr_dict = self.get_dict(self.get_value(cur_level, optionName + '.ocr'))
|
|
|
break
|
|
|
|
|
|
if self.has_option(cur_level, cur_parent + '.ocr'):
|
|
|
- self.warn("%s使用父节点%s的ocr配置", optionName, cur_parent)
|
|
|
+ self.warn("%s使用父节点%s的ocr配置" % (optionName, cur_parent))
|
|
|
ocr_dict = self.get_dict(self.get_value(cur_level, cur_parent + '.ocr'))
|
|
|
break
|
|
|
|
|
|
if self.has_option(cur_level, first_parent + '.ocr'):
|
|
|
- self.warn("%s使用顶层节点%s的ocr配置", optionName, first_parent)
|
|
|
+ self.warn("%s使用顶层节点%s的ocr配置" % (optionName, first_parent))
|
|
|
ocr_dict = self.get_dict(self.get_value(cur_level, first_parent + '.ocr'))
|
|
|
break
|
|
|
|
|
@@ -171,14 +177,15 @@ class CConfigManager(TConfig, CBaseLog):
|
|
|
|
|
|
self.info("%s使用的ocr配置=%" % (optionName, ocr_dict))
|
|
|
|
|
|
-
|
|
|
- def getValueOCRConfig(self, valueName, paths):
|
|
|
- pass
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ def getICONResolutionConfig(self):
|
|
|
+ return self.get_value_dict('Screen', 'shape') if self.has_option('Screen', 'shape') else [1920, 1080]
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
tData = CTData()
|
|
|
upath = UITPathManage(tData)
|
|
|
opc = CConfigManager(r'D:\SAT\resource\MenuTree\RT2851\2851', upath)
|
|
|
-
|
|
|
print opc.getOptionICONConfig("picture")
|