Skip to content

Commit 0dcbde3

Browse files
Merge pull request #3 from BenjaminHalko/update-windows
2 parents 35e490a + ebc377c commit 0dcbde3

File tree

3 files changed

+14
-27
lines changed

3 files changed

+14
-27
lines changed

build-windows.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@echo off
2-
pyinstaller -F -w --add-data crossplatformhelpers/Windows/Helper;Helper --icon icon/icon.ico --add-data translations/translations;translations WiiMusicEditorPlus.py
3-
tar -a -C dist -cf dist\WiiMusicEditorPlus-Windows.zip WiiMusicEditorPlus.exe
2+
pyinstaller -w --noconfirm --add-data crossplatformhelpers/Windows/Helper;Helper --icon icon/icon.ico --add-data translations/translations;translations WiiMusicEditorPlus.py
3+
tar -a -C dist -cf dist\WiiMusicEditorPlus-Windows.zip WiiMusicEditorPlus
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
22

33
timeout 1
4-
del %1
5-
move "%~dp0WiiMusicEditorPlus.exe" %1
4+
tar --verbose -xf "%~dp0downloaded.zip" -C "%~p1\.."
5+
del "%~dp0downloaded.zip"
66
start "" %1

update.py

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from os import path, remove
2-
import pathlib
32
from editor import HelperPath, LoadSetting, FullPath, currentSystem, ChooseFromOS, version, SavePath, GivePermission
43
from PyQt5.QtWidgets import QDialog
54
from PyQt5.QtCore import QThread, pyqtSignal, Qt
@@ -8,22 +7,19 @@
87
from requests import get, ConnectionError, Timeout
98
from zipfile import ZipFile
109
from sys import exit as sys_exit
11-
from shutil import copyfile, rmtree, move
10+
from shutil import copyfile, rmtree
1211
from subprocess import call
13-
from warning import ShowWarning
1412

1513
class Progress():
1614
def update(self, op_code, cur_count, max_count=None, message=''):
1715
if(op_code > 10): UpdateThread.progress.emit(cur_count/max_count*100)
18-
legacymode = False
1916

2017
class Download(QThread):
2118
progress = pyqtSignal(int)
2219
done = pyqtSignal()
2320
version = "null"
2421

2522
def run(self):
26-
global legacymode
2723
file = open(SavePath()+"/downloaded.zip", "wb")
2824
with get("https://github.com/BenjaminHalko/WiiMusicEditorPlus/releases/download/"+self.version+"/WiiMusicEditorPlus-"+currentSystem+".zip",stream=True) as response:
2925
total = int(response.headers['content-length'])
@@ -35,22 +31,20 @@ def run(self):
3531

3632
file.close()
3733

38-
if(path.isfile(SavePath()+"/WiiMusicEditorPlus"+ChooseFromOS([".exe",".app",""]))): remove(SavePath()+"/WiiMusicEditorPlus"+ChooseFromOS([".exe",".app",""]))
39-
elif(path.isdir(SavePath()+"/WiiMusicEditorPlus"+ChooseFromOS([".exe",".app",""]))): rmtree(SavePath()+"/WiiMusicEditorPlus"+ChooseFromOS([".exe",".app",""]))
40-
41-
if(currentSystem != "Mac"):
34+
if(currentSystem == "Linux"):
35+
if(path.isfile(SavePath()+"/WiiMusicEditorPlus")): remove(SavePath()+"/WiiMusicEditorPlus")
4236
zip = ZipFile(SavePath()+"/downloaded.zip")
4337
zip.extractall(SavePath())
44-
if(len(zip.infolist()) > 5): legacymode = True
4538
zip.close()
46-
else:
39+
elif (currentSystem == "Mac"):
40+
if(path.isdir(SavePath()+"/WiiMusicEditorPlus.app")): rmtree(SavePath()+"/WiiMusicEditorPlus.app")
4741
zip = ZipFile(SavePath()+"/downloaded.zip")
4842
for file in zip.infolist():
4943
zip.extract(file, SavePath())
5044
call(["chmod","u+x",path.join(SavePath(), file.filename)])
5145
zip.close()
52-
53-
remove(SavePath()+"/downloaded.zip")
46+
47+
if(currentSystem != "Windows"): remove(SavePath()+"/downloaded.zip")
5448
UpdateThread.done.emit()
5549

5650
class UpdateWindow(QDialog,Ui_Update):
@@ -94,14 +88,7 @@ def restart(self):
9488
copyfile(HelperPath()+"/Extra/update"+updateExt,SavePath()+"/update"+updateExt)
9589

9690
if(currentSystem == "Windows"):
97-
if(legacymode):
98-
move(SavePath()+"/WiiMusicEditorPlus",pathlib.Path(FullPath).parent)
99-
if(path.exists(SavePath()+"/update.bat")): remove(SavePath()+"/update.bat")
100-
copyfile(HelperPath()+"/Extra/update-legacy.bat",SavePath()+"/update.bat")
101-
ShowWarning(f"Program format changed to folder\nNew path of program: {pathlib.Path(FullPath).parent}/WiiMusicEditorPlus/WiiMusicEditorPlus.exe",self)
102-
Popen([SavePath()+"/update.bat",FullPath])
103-
Popen(path.dirname(FullPath)+"/WiiMusicEditorPlus/WiiMusicEditorPlus.exe")
104-
else: Popen([SavePath()+"/update.bat",FullPath])
91+
Popen([SavePath()+"/update.bat",FullPath])
10592
else:
10693
GivePermission(SavePath()+"/update.sh")
10794
if(currentSystem == "Linux"): GivePermission(SavePath()+'/WiiMusicEditorPlus')
@@ -117,7 +104,7 @@ def restart(self):
117104
def CheckForUpdate():
118105
try:
119106
tag = GetReleaseTag()
120-
if(tag != version and tag != "test"): return tag
107+
if(tag != version): return tag
121108
else: return "null"
122109
except (ConnectionError, Timeout):
123110
return "null"
@@ -137,6 +124,6 @@ def GetReleaseTag():
137124
if(j["name"] == f"WiiMusicEditorPlus-{currentSystem}.zip"):
138125
looking = False
139126
break
140-
except Exception:
127+
except:
141128
i = 0
142129
return data[i]["tag_name"]

0 commit comments

Comments
 (0)