-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDerivateSwitch.py
139 lines (109 loc) · 4.97 KB
/
DerivateSwitch.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
import os
import sys
import stat
import shutil
import glob
os.chdir('..')
CURRENT_DIR_PATH = os.getcwd()
print CURRENT_DIR_PATH
print "Cleaning sandbox ..."
if os.path.isdir('.\obj'):
for root, dirs, files in os.walk('.\obj'):
for d in dirs:
os.chmod(os.path.join(root, d), 0xFFF)
for f in files:
os.chmod(os.path.join(root, f), 0xFFF)
if os.path.isdir('.\src'):
for root, dirs, files in os.walk('.\src'):
for d in dirs:
os.chmod(os.path.join(root, d), 0xFFF)
for f in files:
os.chmod(os.path.join(root, f), 0xFFF)
os.chdir('..')
print "Removing directories ..."
os.chdir(CURRENT_DIR_PATH)
if os.path.isdir('.\obj'):
shutil.rmtree('.\obj', False, None)
if os.path.isdir('.\src'):
shutil.rmtree('.\src', False, None)
print "Sandbox cleaned !"
os.chdir('./source')
print (os.getcwd())
# Checking Current file to find the currnet working variant
try:
os.chmod("Current", 0xFFF)
f = open("Current","r") #opens Current file name"
except IOError as e:
print ("Current file not found! Please cresync from IMS for default varient")
exit()
Current_Varient = f.readline()
f.close()
print(Current_Varient)
if (Current_Varient == '2M'):
print ("This is 2M variant")
CURRENT_DERIVATE='2M'
elif (Current_Varient == '6M'):
print ("This is 6M variant")
CURRENT_DERIVATE='6M'
elif (Current_Varient == '10M'):
print ("This is 10M variant")
CURRENT_DERIVATE='10M'
elif (Current_Varient == 'notest'):
print ("This is notest variant")
CURRENT_DERIVATE='notest'
else:
print ("This is 4M variant")
CURRENT_DERIVATE='4M'
TARGET_DERIVATE=sys.argv[1] # Takes target variant from cmd line argv
print "Transitioning from "+CURRENT_DERIVATE+" to "+TARGET_DERIVATE+"..."
os.chdir('..')
os.chdir('..')
if CURRENT_DERIVATE != TARGET_DERIVATE:
print "Saving "+CURRENT_DERIVATE+" files"
for root, dirs, files in os.walk(os.getcwd()):
for file in files:
try:
if (file.endswith(str('.'+CURRENT_DERIVATE))):
os.chmod(os.path.join(root, file), 0xFFF)
os.chmod(os.path.join(root, file.replace(("."+CURRENT_DERIVATE),'')), 0xFFF)
shutil.copy(os.path.join(root, file.replace(("."+CURRENT_DERIVATE),'')), os.path.join(root, file.replace(CURRENT_DERIVATE,'')+CURRENT_DERIVATE))
print "Saved "+CURRENT_DERIVATE+" file "+file.replace("."+CURRENT_DERIVATE,'')+" as "+file.replace(CURRENT_DERIVATE,'')+CURRENT_DERIVATE
elif ((CURRENT_DERIVATE == '4M') and (file.endswith(str('.'+TARGET_DERIVATE)))):
os.chmod(os.path.join(root, file), 0xFFF)
os.chmod(os.path.join(root, file.replace(("."+TARGET_DERIVATE),'')), 0xFFF)
shutil.copy(os.path.join(root, file.replace(("."+TARGET_DERIVATE),'')), os.path.join(root, file.replace(TARGET_DERIVATE,'')+CURRENT_DERIVATE))
print "Saving "+CURRENT_DERIVATE+" file "+file.replace(("."+TARGET_DERIVATE),'')+" as: "+file.replace(TARGET_DERIVATE,'')+CURRENT_DERIVATE
except WindowsError as e:
pass
for root, dirs, files in os.walk(os.getcwd()):
for file in files:
try:
if (file.endswith(str('.4M'))):
os.chmod(os.path.join(root, file), 0xFFF)
os.chmod(os.path.join(root, file.replace(".4M",'')), 0xFFF)
print "Restoring 4M default file "+file
shutil.copy(os.path.join(root, file), os.path.join(root, file.replace(".4M",'')))
except OSError as e:
pass
for root, dirs, files in os.walk(os.getcwd()):
for file in files:
if (file.endswith(str('.'+TARGET_DERIVATE))):
try:
os.chmod(os.path.join(root, file), 0xFFF)
os.chmod(os.path.join(root, file.replace(("."+TARGET_DERIVATE),'')), 0xFFF)
print "Setting "+TARGET_DERIVATE+" file:"+file+" to working file "+file.replace(("."+TARGET_DERIVATE),'')
shutil.copy(os.path.join(root, file), os.path.join(root, file.replace(("."+TARGET_DERIVATE),'')))
except WindowsError as e:
pass
os.chdir(CURRENT_DIR_PATH)
os.chdir('.\source')
Ideas_update_cmd = "call .\..\etools\TsStarter.cmd update"
os.system(Ideas_update_cmd) #on windows to update Ideas
Cessar_CT_update_cmd = "call .\..\etools\TsStarter.cmd CessarUpdater -pdr"
os.system(Cessar_CT_update_cmd) #on windows to update Cessar CT
f = open("Current","w+")
f.write(TARGET_DERIVATE)
f.close()
print "\nTransition "+TARGET_DERIVATE+" done !"
else:
print "Already on "+CURRENT_DERIVATE+", nothing for transition !"