forked from AgoraIO/API-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeycenter.py
More file actions
51 lines (44 loc) · 1.45 KB
/
keycenter.py
File metadata and controls
51 lines (44 loc) · 1.45 KB
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
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import re
import os
def main():
appId = ""
if "AGORA_APP_ID" in os.environ:
appId = os.environ["AGORA_APP_ID"]
token = ""
fileDirectory = ""
if "File_Directory" in os.environ:
fileDirectory = os.environ["File_Directory"]
# KeyCenter.swift
KeyCenterPath = fileDirectory + "/KeyCenter.swift"
print("KeyCenterPath: %s" %KeyCenterPath)
try:
f = open(KeyCenterPath, 'r+')
content = f.read()
appString = "\"" + appId + "\""
tokenString = "\"" + token + "\""
contentNew = re.sub(r'<#YOUR APPID#>', appString, content)
contentNew = re.sub(r'<#YOUR AppId#>', appString, contentNew)
contentNew = re.sub(r'<#YOUR Certificate#>', tokenString, contentNew)
f.seek(0)
f.write(contentNew)
f.truncate()
except IOError:
print("Swift File is not accessible.")
# KeyCenter.m
KeyCenterPath = fileDirectory + "/KeyCenter.m"
try:
f = open(KeyCenterPath, 'r+')
content = f.read()
appString = "@\"" + appId + "\""
tokenString = "@\"" + token + "\""
contentNew = re.sub(r'<#Your App Id#>', appString, content)
contentNew = re.sub(r'<#Temp Access Token#>', tokenString, contentNew)
f.seek(0)
f.write(contentNew)
f.truncate()
except IOError:
print("OC File is not accessible.")
if __name__ == "__main__":
main()