-
Notifications
You must be signed in to change notification settings - Fork 18
/
metainfo_link_generator.py
91 lines (80 loc) · 4.41 KB
/
metainfo_link_generator.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
import sys, os
if sys.version_info[0] < 3:
raw_input("You need to run this with Python 3!\nPress Enter to exit...")
sys.exit(1)
import subprocess
try:
import configparser
except:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'configparser'], stdout=subprocess.DEVNULL)
try:
import configparser
except:
input("ERROR! Installation of %s failed!\nPress Enter to exit..." % required)
sys.exit(1)
import stat
config = configparser.ConfigParser()
config.optionxform = str
us = input("\nDo you want to convert US(NAR)/CN/JP/KR(RoW) to EU unit? Enter y if yes, or just press enter if no: ")
print("Reading metainfo2.txt...")
config.read("metainfo2.txt")
if len(config) == 1:
input("\nERROR! Cannot open metainfo2.txt. Press any key to exit...")
exit()
config2 = configparser.ConfigParser()
config2.optionxform = str
new_id = ""
yes = ['y', 'yes', 'Y', 'YES']
for section in config.sections():
if not config2.has_section(section):
config2.add_section(section)
for option in config.options(section):
if option == "RequiredVersionOfDM":
config2.set(section, option, '"0"')
elif us in yes and option.startswith("Region") and config.get(section, option) == '"Europe"':
config2.set(section, "Region", '"Europe"')
config2.set(section, "Region2", '"RoW"')
config2.set(section, "Region3", '"USA"')
config2.set(section, "Region4", '"CN"')
elif us in yes and option.startswith("Variant") and config.get(section, option) == '"17214"':
config2.set(section, option, '"17218"')
elif us in yes and option.startswith("Variant") and config.get(section, option) == '"17216"':
config2.set(section, option, '"17220"')
elif us in yes and option.startswith("Variant") and config.get(section, option) == '"17226"':
config2.set(section, option, '"17219"')
elif us in yes and option.startswith("Variant") and config.get(section, option) == '"17225"':
config2.set(section, option, '"17221"')
elif us in yes and option.startswith("Variant") and config.get(section, option) == '"17217"':
config2.set(section, option, '"17222"')
elif us in yes and option.startswith("Variant") and config.get(section, option) == '"17215"':
config2.set(section, option, '"17223"')
elif us in yes and option.startswith("Variant") and config.get(section, option) == '"17204"':
config2.set(section, option, '"17208"')
elif us in yes and option.startswith("Variant") and config.get(section, option) == '"17206"':
config2.set(section, option, '"17210"')
elif us in yes and option.startswith("Variant") and config.get(section, option) == '"17207"':
config2.set(section, option, '"17212"')
elif us in yes and option.startswith("Variant") and config.get(section, option) == '"17205"':
config2.set(section, option, '"17213"')
else:
config2.set(section, option, config.get(section, option))
split_section = section.split("\\")
if new_id == "" and len(split_section) == 5 and split_section[0] == 'cpu' and split_section[1] == 'customerupdateinfos':
new_id = split_section[2]
print("Found ID: " + str(new_id))
id = input('Enter SWDL HwVersion of your unit (you can find it in mibstd2_toolbox>mib_info): ').strip()
print("Linking ID: " + str(id) + " to ID: " + str(new_id))
if id and new_id and "\\" + new_id + "\\" in section:
newsection = section.replace("\\" + new_id + "\\", "\\" + id + "\\")
if not config2.has_section(newsection):
config2.add_section(newsection)
config2.set(newsection, "Link", '"[' + section + ']"')
if us in yes:
print("\nIMPORTANT! This metainfo2.txt can only be used on US(NAR)/CN/JP/KR(RoW) unit for convertion to EU unit!")
print("Before starting the update, run mibstd2_toolbox>Tools>Patch tsd.mibstd2.system.swdownload to accept any metainfo2.txt!!!")
with open("metainfo2.old", "w") as config_file:
config.write(config_file)
os.chmod("metainfo2.txt", 0o777)
with open("metainfo2.txt", "w") as config_file:
config2.write(config_file)
input("\nDone. Press Enter to exit...")