-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigParser.py
236 lines (179 loc) · 8.58 KB
/
ConfigParser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
import json
from Utility.HeaderBase import *
from pathlib import Path
from SystemBase import *
from Base.AgoraSDKInfo import *
from Utility.PathConfiger import *
from FileIO.FileUtility import *
path_val = Path("/Users/admin/Documents/PyUnrealBuildSystem/Config/Config.json")
class IOSCertInfo:
def __init__(self,signing_identity,provisioning_profile,name_mobileprovision,path_mobileprovision,provisioning_profile_specifier,team_id):
self.__signing_identity = signing_identity
self.__provisioning_profile = provisioning_profile
self.__name_mobileprovision = name_mobileprovision
self.__path_mobileprovision = Path(path_mobileprovision)
self.__provisioning_profile_specifier = provisioning_profile_specifier
self.__team_id = team_id
@property
def get_signing_identity(self):
return self.__signing_identity
## currently get it from UE Config
@property
def get_provisioning_profile(self):
return self.__provisioning_profile
@property
def get_filename_mobileprovision(self):
return self.__name_mobileprovision
@property
def get_filepath_mobileprovision(self):
return self.__path_mobileprovision
## use security cms -D -i [path_mobile_provision]
## to check UUID
## could be used in Xcode[provisioning_profile_specifier]
@property
def get_provisioning_profile_specifier(self):
return self.__provisioning_profile_specifier
@property
def get_team_id(self):
return self.__team_id
class ConfigParser(BaseSystem):
_instance = None
_initialized = False
## RTC+RTM
SDKLOADTYPELIST="RTC"
UEConfigData = None
SDKConfigData = None
IOSCertData = None
def __new__(cls, *args, **kwargs):
if not cls._instance:
cls._instance = super().__new__(cls, *args, **kwargs)
cls._instance._initialized = False
return cls._instance
def __init__(self) -> None:
if not self._initialized:
super().__init__()
self._initialized = True
def Get():
return ConfigParser()
def Init(self,SDKLoadType = "RTC"):
self.SDKLOADTYPELIST = SDKLoadType
self.ParseConfig()
def ParseConfig(self):
self.ParseUEConfig()
self.ParseSDKConfig()
self.ParseIOSCertConfig()
def ParseUEConfig(self):
## Load Basic Config
base_config_path=Path("Config/UEConfig/Config.json")
base_config_file = open(base_config_path)
base_config_json_data = json.load(base_config_file)
## Load Platforms Config
platform_config_path = base_config_path.parent.joinpath("Platforms",self.GetHostPlatform(),"Config.json")
platform_config_file = open(platform_config_path)
platform_config_json_data = json.load(platform_config_file)
base_config_json_data.update(platform_config_json_data)
PrintLog("UE Config: " + str(base_config_json_data))
self.UEConfigData = base_config_json_data
def ParseSDKConfig(self):
# SDKTYPELIST = self.SDKLOADTYPELIST.split('+')
# base_config_json_data = None
# for SDKTYPE in SDKTYPELIST:
# one_type_config_path=Path("Config/SDKConfig").joinpath(SDKTYPE,"Config.json")
# one_type_config_file = open(one_type_config_path)
# one_type_config_json_data = json.load(one_type_config_file)
# if base_config_json_data == None:
# base_config_json_data = one_type_config_json_data
# else:
# base_config_json_data.update(one_type_config_json_data)
base_config_json_data = None
SDKTYPE = self.SDKLOADTYPELIST
one_type_config_path=Path("Config/SDKConfig").joinpath(SDKTYPE,"Config.json")
one_type_config_file = open(one_type_config_path)
one_type_config_json_data = json.load(one_type_config_file)
if base_config_json_data == None:
base_config_json_data = one_type_config_json_data
else:
base_config_json_data.update(one_type_config_json_data)
platform_config_path = Path("Config/SDKConfig").joinpath("Platforms",self.GetHostPlatform(),"Config.json")
platform_config_file = open(platform_config_path)
platform_config_json_data = json.load(platform_config_file)
base_config_json_data.update(platform_config_json_data)
PrintLog("SDK Config: " + str(base_config_json_data))
self.SDKConfigData = base_config_json_data
def ParseIOSCertConfig(self):
ios_cert_config_path = Path("Config/UEConfig/Platforms/IOS/Certificate.json")
ios_cert_config_path = open(ios_cert_config_path)
config_path_json_data = json.load(ios_cert_config_path)
PrintLog("Available IOS Certificate: " + str(config_path_json_data))
self.IOSCertData = config_path_json_data
def GetAllAvailableEngineList(self):
available_list = []
for engine_ver in self.UEConfigData["EngineList"]:
available_list.append(engine_ver)
return available_list
def GetDefaultEnginePath(self,ver):
return self.UEConfigData["EngineList"][ver]["Path"]
def GetDefaultPluginRepo(self):
return self.SDKConfigData["defaultpluginrepo"]
def GetRTCSDKURL(self,sdkinfo:AgoraSDKInfo):
key_type = "url_full"
if sdkinfo.Get_SDKIsAudioOnly() == True:
key_type = "url_audioonly"
return self.SDKConfigData[sdkinfo.Get_SDKVer()][key_type]
def GetRTCSDKNativeURL_IOS(self,sdkinfo:AgoraSDKInfo):
key_type = "url_native_ios"
if sdkinfo.Get_SDKIsAudioOnly():
key_type = "url_native_ios_audioonly"
return self.SDKConfigData[sdkinfo.Get_SDKVer()][key_type]
def GetRTCSDKNativeURL_Android(self,sdkinfo:AgoraSDKInfo):
key_type = "url_native_android"
if sdkinfo.Get_SDKIsAudioOnly():
key_type = "url_native_android_audioonly"
return self.SDKConfigData[sdkinfo.Get_SDKVer()][key_type]
def GetRTCSDKNativeURL_Win(self,sdkinfo:AgoraSDKInfo):
key_type = "url_native_win"
return self.SDKConfigData[sdkinfo.Get_SDKVer()][key_type]
def GetRTCSDKNativeURL_Mac(self,sdkinfo:AgoraSDKInfo):
key_type = "url_native_mac"
return self.SDKConfigData[sdkinfo.Get_SDKVer()][key_type]
## IOS Certificate
def GetAllIOSCertificates(self):
return self.IOSCertData.items()
def IsIOSCertValid(self,tag_name):
bIsValid = False
if self.IOSCertData and self.IOSCertData[tag_name]:
cert = self.IOSCertData[tag_name]["signing_identity"]
mobileprovision = self.IOSCertData[tag_name]["provisioning_profile"]
if cert and len(cert) > 0 and mobileprovision and len(mobileprovision) > 0:
bIsValid = True
else:
PrintErr("[Cert %s] is not a valid certificate" % tag_name)
return bIsValid
def GetOneIOSCertificate(self,tag_name) -> IOSCertInfo:
## Get current script working dir
if not self.IsIOSCertValid(tag_name):
return None
current_dir = Path(__file__).parent
base_path = current_dir / Path("Config/UEConfig/Platforms/IOS/Certs")
return IOSCertInfo(
signing_identity = self.IOSCertData[tag_name]["signing_identity"],
provisioning_profile = self.IOSCertData[tag_name]["provisioning_profile"],
name_mobileprovision = self.IOSCertData[tag_name]["mobileprovision_filename"],
path_mobileprovision = str(base_path / self.IOSCertData[tag_name]["mobileprovision_filename"]),
provisioning_profile_specifier = self.IOSCertData[tag_name]["provisioning_profile_specifier"],
team_id = self.IOSCertData[tag_name]["team_id"]
)
def CopyAllMobileProvisionsToDstPath(self):
if SystemHelper.Get().GetHostPlatform() == SystemHelper.Mac_HostName():
current_dir = Path(__file__).parent
src_path = current_dir / Path("Config/UEConfig/Platforms/IOS/Certs")
dst_path = Path(PathConfiger.GetMobileProvisionCachePath())
if dst_path.exists():
for file in src_path.glob("*.mobileprovision"):
dst_file = dst_path / file.name
FileUtility.CopyFile(file, dst_file)
### For Resources Related
def GetResourcesRootPath(self,resource_index_key,resource_tag_name):
current_dir = Path(__file__).parent
final_path = current_dir / Path("Config/UEConfig/Resources") / resource_index_key / resource_tag_name
return final_path