9
9
from github import Github
10
10
import wget
11
11
import subprocess
12
- from shutil import copyfile
12
+ import shutil
13
13
14
14
15
15
class ReleaseManager (MakesmithInitFuncs ):
@@ -50,7 +50,7 @@ def checkForLatestPyRelease(self):
50
50
tag_float = float (tag_name )
51
51
eligible = False
52
52
if not enableExperimental :
53
- if not self .isExperimental (tag_name ):
53
+ if not self .isExperimental (release ):
54
54
eligible = True
55
55
else :
56
56
eligible = True
@@ -74,19 +74,16 @@ def checkForLatestPyRelease(self):
74
74
except Exception as e :
75
75
print ("Error checking pyrelease: " + str (e ))
76
76
77
- def isExperimental (self , tag ):
77
+ def isExperimental (self , release ):
78
78
'''
79
- Deternmines if release is experimental. All even releases are stable, odd releases are experimental
79
+ Deternmines if release is experimental. Pre-Releases are experimental.
80
80
:param tag:
81
81
:return:
82
82
'''
83
- if float (tag ) <= 0.931 : # all releases before now are 'stable'
84
- return False
85
- lastDigit = tag [- 1 ]
86
- if (int (lastDigit ) % 2 ) == 0 : # only even releases are 'stable'
87
- return False
88
- else :
83
+ if release .prerelease :
89
84
return True
85
+ else :
86
+ return False
90
87
91
88
def processAbsolutePath (self , path ):
92
89
index = path .find ("main.py" )
@@ -106,36 +103,78 @@ def updatePyInstaller(self, bypassCheck = False):
106
103
except :
107
104
print ("error cleaning download directory: " , filePath )
108
105
print ("---" )
106
+ print ("Downloading new WebControl release..." )
109
107
if self .data .pyInstallPlatform == "win32" or self .data .pyInstallPlatform == "win64" :
110
108
filename = wget .download (self .data .pyInstallUpdateBrowserUrl , out = home + "\\ .WebControl\\ downloads" )
111
109
else :
112
110
filename = wget .download (self .data .pyInstallUpdateBrowserUrl , out = home + "/.WebControl/downloads" )
113
- print (filename )
111
+ print ("Successfully downloaded new release to:" + filename )
114
112
115
113
if self .data .platform == "PYINSTALLER" :
116
114
lhome = os .path .join (self .data .platformHome )
117
115
else :
118
116
lhome = "."
119
- if self .data .pyInstallPlatform == "win32" or self .data .pyInstallPlatform == "win64" :
120
- path = lhome + "/tools/upgrade_webcontrol_win.bat"
121
- copyfile (path , home + "/.WebControl/downloads/upgrade_webcontrol_win.bat" )
122
- path = lhome + "/tools/7za.exe"
123
- copyfile (path , home + "/.WebControl/downloads/7za.exe" )
124
- self .data .pyInstallInstalledPath = self .data .pyInstallInstalledPath .replace ('/' , '\\ ' )
125
- program_name = home + "\\ .WebControl\\ downloads\\ upgrade_webcontrol_win.bat"
126
117
118
+ print ("Creating target version directory..." )
119
+ target_dir = self .data .pyInstallInstalledPath + '_next'
120
+ if os .path .exists (target_dir ):
121
+ print ("New release directory already exists, removing it" )
122
+ shutil .rmtree (target_dir )
123
+ os .mkdir (target_dir )
124
+ print ("Creating target version directory DONE" )
125
+
126
+ print ("Unzipping new release..." )
127
+ if self .data .pyInstallPlatform == "win32" or self .data .pyInstallPlatform == "win64" :
128
+ command = [
129
+ lhome + "/tools/7za.exe" ,
130
+ "x" ,
131
+ "-y" ,
132
+ filename ,
133
+ "-o" ,
134
+ target_dir
135
+ ]
136
+ print (command )
137
+ subprocess .run (command )
138
+ else :
139
+ command = [
140
+ "tar" ,
141
+ "-zxf" ,
142
+ filename ,
143
+ "-C" ,
144
+ target_dir
145
+ ]
146
+ print (command )
147
+ subprocess .run (command )
148
+ print ("Unzipping new release DONE" )
149
+
150
+ print ("Upgrade script..." )
151
+ print ("Checking if it needs to be run for platform: " + self .data .pyInstallPlatform )
152
+ if self .data .pyInstallPlatform == "win32" or self .data .pyInstallPlatform == "win64" :
153
+ upgrade_script_path = target_dir + "\\ tools\\ upgrade_" + self .data .pyInstallPlatform + ".bat"
154
+ else :
155
+ upgrade_script_path = target_dir + "/tools/upgrade_" + self .data .pyInstallPlatform + ".sh"
156
+ if os .path .exists (upgrade_script_path ):
157
+ print ("Yes, running it" )
158
+ self .make_executable (upgrade_script_path )
159
+ subprocess .run ([upgrade_script_path ])
127
160
else :
128
- path = lhome + "/tools/upgrade_webcontrol.sh"
129
- copyfile (path , home + "/.WebControl/downloads/upgrade_webcontrol.sh" )
130
- program_name = home + "/.WebControl/downloads/upgrade_webcontrol.sh"
131
- self .make_executable (home + "/.WebControl/downloads/upgrade_webcontrol.sh" )
132
- tool_path = home + "\\ .WebControl\\ downloads\\ 7za.exe"
133
- arguments = [filename , self .data .pyInstallInstalledPath , tool_path ]
134
- command = [program_name ]
135
- command .extend (arguments )
136
- print ("popening" )
137
- print (command )
138
- subprocess .Popen (command )
161
+ print ("No upgrade script needed." )
162
+ print ("Upgrade script DONE" )
163
+
164
+ print ("Backing up the current install..." )
165
+ backup_path = self .data .pyInstallInstalledPath + '_old'
166
+ print ("Backup location: " + backup_path )
167
+ if os .path .exists (backup_path ):
168
+ print ("Old backup found, removing it" )
169
+ shutil .rmtree (backup_path )
170
+ os .rename (self .data .pyInstallInstalledPath , self .data .pyInstallInstalledPath + '_old' )
171
+ print ("Backing up the current install DONE" )
172
+
173
+ print ("Moving the target version in place..." )
174
+ os .rename (target_dir , self .data .pyInstallInstalledPath )
175
+ print ("Moving the target version in place DONE" )
176
+
177
+ print ("WebControl upgrade complete, shutting down to make way to the target version" )
139
178
return True
140
179
return False
141
180
@@ -165,7 +204,7 @@ def update(self, version):
165
204
self .data .pyInstallUpdateBrowserUrl = asset .browser_download_url
166
205
print (self .data .pyInstallUpdateBrowserUrl )
167
206
return self .updatePyInstaller (True )
168
- print ("hmmm.. issue" )
207
+ print ("Couldn't find a suitable file for the current platform and target version: " + version )
169
208
return False
170
209
171
210
0 commit comments