8
8
from datetime import date
9
9
from PySide6 import __file__ as PySide6_File
10
10
from PySide6 .QtCore import Qt , QObject , Signal
11
- from PySide6 .QtCore import QCoreApplication as QCA , QThreadPool
11
+ from PySide6 .QtCore import QCoreApplication as QCA , QThreadPool , QTimer
12
12
from PySide6 .QtGui import QColor , QPixmap , QIcon , QTextCursor
13
13
from QEasyWidgets import QFunctions as QFunc
14
14
from QEasyWidgets import QTasks
25
25
26
26
##############################################################################################################################
27
27
28
+ # Get current path
29
+ currentPath = EasyUtils .getCurrentPath ()
30
+
31
+ # Get current directory
32
+ currentDir = Path (currentPath ).parent .as_posix ()
33
+
34
+ # Set path to store log
35
+ logPath = EasyUtils .normPath (Path (currentDir ).joinpath ('log.txt' ))
36
+
37
+ # Set directory to load static dependencies
38
+ resourceDir = EasyUtils .getBaseDir (searchMEIPASS = True ) or currentDir
39
+
40
+ # Check whether python file is compiled
41
+ _ , isFileCompiled = EasyUtils .getFileInfo ()
42
+
43
+ # Get current version (assume resourceDir is the name of current version after being compiled)
44
+ currentVersion = Path (resourceDir ).name if isFileCompiled else 'beta version'
45
+
46
+ ##############################################################################################################################
47
+
28
48
# Change working directory to current directory
29
49
os .chdir (currentDir )
30
50
31
51
32
52
# Parse path settings
33
53
parser = argparse .ArgumentParser ()
34
- parser .add_argument ("--updater" , help = "path to updater" , default = Path (currentDir ).joinpath ('Updater.py' if isFileCompiled == False else 'Updater.exe' ))
35
- parser .add_argument ("--core" , help = "dir of core files" , default = Path (resourceDir ).joinpath ('EVT_Core' ))
36
- parser .add_argument ("--manifest" , help = "path to manifest.json" , default = Path (resourceDir ).joinpath ('manifest.json' ))
37
- parser .add_argument ("--requirements" , help = "path to requirements.txt" , default = Path (resourceDir ).joinpath ('requirements.txt' ))
38
- parser .add_argument ("--dependencies" , help = "dir of dependencies" , default = Path (currentDir ).joinpath ('' ))
39
- parser .add_argument ("--models" , help = "dir of models" , default = Path (currentDir ).joinpath ('Models' ))
40
- parser .add_argument ("--output" , help = "dir of output" , default = Path (currentDir ).joinpath ('' ))
41
- parser .add_argument ("--profile" , help = "dir of profile" , default = Path (currentDir ).joinpath ('' ))
54
+ parser .add_argument ("--updater" , help = "path to updater" , default = Path (resourceDir ).joinpath ('updater.exe' ) if isFileCompiled else Path (currentDir ).joinpath ('updater.py' ))
55
+ parser .add_argument ("--core" , help = "dir of core files" , default = Path (resourceDir ).joinpath ('EVT_Core' ))
56
+ parser .add_argument ("--manifest" , help = "path to manifest.json" , default = Path (resourceDir ).joinpath ('manifest.json' ))
57
+ parser .add_argument ("--requirements" , help = "path to requirements.txt" , default = Path (resourceDir ).joinpath ('requirements.txt' ))
58
+ parser .add_argument ("--dependencies" , help = "dir of dependencies" , default = Path (currentDir ).joinpath ('' ))
59
+ parser .add_argument ("--models" , help = "dir of models" , default = Path (currentDir ).joinpath ('Models' ))
60
+ parser .add_argument ("--output" , help = "dir of output" , default = Path (currentDir ).joinpath ('' ))
61
+ parser .add_argument ("--profile" , help = "dir of profile" , default = Path (currentDir ).joinpath ('' ))
62
+ parser .add_argument ("--deprecatedVersion" , help = "deprecated version" , default = None )
42
63
args = parser .parse_args ()
43
64
44
65
updaterPath = args .updater
49
70
modelDir = args .models
50
71
outputDir = args .output
51
72
profileDir = args .profile
73
+ deprecatedVersion = args .deprecatedVersion
52
74
53
75
54
76
# Set up client config
55
77
configDir = EasyUtils .normPath (Path (profileDir ).joinpath ('config' ))
56
78
configPath = EasyUtils .normPath (Path (configDir ).joinpath ('config.ini' ))
57
79
config = EasyUtils .configManager (configPath )
58
- config .editConfig ('Info' , 'currentVersion' , str (currentVersion ))
59
- config .editConfig ('Info' , 'executerName' , str (EasyUtils .getFileInfo ()[0 ]))
60
80
61
81
62
82
# Set up environment variables while python file is not compiled
@@ -154,7 +174,6 @@ def __init__(self):
154
174
self .MonitorUsage .start ()
155
175
156
176
def closeEvent (self , event ):
157
- config .editConfig ('Info' , 'executerName' , '' )
158
177
FunctionSignals .Signal_TaskStatus .connect (lambda : QApplication .instance ().exit ())
159
178
FunctionSignals .Signal_ForceQuit .emit ()
160
179
@@ -602,19 +621,31 @@ def showTTSResult(self, mediaPath):
602
621
)
603
622
ChildWindow_TTS .exec ()
604
623
605
- def chkUpdate (self ):
624
+ def chkUpdate (self , runUpdateChecker : bool ):
625
+ recordedVersion = deprecatedVersion or config .getValue ('Info' , 'RecordedVersion' , currentVersion )
626
+ if not EasyUtils .isVersionSatisfied (recordedVersion , currentVersion ):
627
+ deprecatedDir = Path (resourceDir ).parent .joinpath (recordedVersion ).as_posix ()
628
+ time .sleep (3 )
629
+ try :
630
+ shutil .rmtree (deprecatedDir )
631
+ except :
632
+ pass
633
+ else :
634
+ config .editConfig ('Info' , 'RecordedVersion' , currentVersion )
635
+
606
636
FunctionSignals .Signal_ReadyToUpdate .connect (
607
- lambda DownloadURL , VersionInfo : (
637
+ lambda downloadURL , versionInfo : (
608
638
MessageBoxBase .pop (None ,
609
639
QMessageBox .Question , "Ask" ,
610
640
text = "检测到可用的新版本,是否更新?\n New version available, wanna update?" ,
611
- detailedText = VersionInfo ,
641
+ detailedText = versionInfo ,
612
642
buttons = QMessageBox .Yes | QMessageBox .No ,
613
643
buttonEvents = {
614
644
QMessageBox .Yes : lambda : (
615
645
config .editConfig ('Updater' , 'Asked' , 'True' ),
616
- subprocess .Popen (f'{ "python" if isFileCompiled == False else "" } "{ updaterPath } " --config "{ configPath } "' , shell = True , env = os .environ ),
617
- QApplication .instance ().exit ()
646
+ subprocess .Popen (f'{ "python" if isFileCompiled == False else "" } "{ updaterPath } " --programPath "{ currentPath } " --currentVersion { currentVersion } --downloadURL "{ downloadURL } "' , shell = True , env = os .environ ),
647
+ QApplication .instance ().exit (),
648
+ sys .exit (0 ) # In case the main event loop is not entered
618
649
),
619
650
QMessageBox .No : lambda : (
620
651
config .editConfig ('Updater' , 'Asked' , 'False' ),
@@ -623,7 +654,6 @@ def chkUpdate(self):
623
654
)
624
655
)
625
656
)
626
-
627
657
Function_SetMethodExecutor (
628
658
executeMethod = Function_UpdateChecker ,
629
659
executeParams = (
@@ -635,14 +665,14 @@ def chkUpdate(self):
635
665
),
636
666
threadPool = self .threadPool ,
637
667
parentWindow = self ,
638
- )
668
+ ) if runUpdateChecker else None
639
669
640
670
def main (self ):
641
671
'''
642
672
Main funtion to orgnize all the subfunctions
643
673
'''
644
674
# Check for updates
645
- self .chkUpdate () if config .getValue ('Settings' , 'AutoUpdate' , 'Enabled' ) == 'Enabled' else None
675
+ self .chkUpdate (config .getValue ('Settings' , 'AutoUpdate' , 'Enabled' ) == 'Enabled' ) if isFileCompiled else None
646
676
647
677
# Logo
648
678
self .setWindowIcon (QIcon (EasyUtils .normPath (Path (resourceDir ).joinpath ('assets/images/Logo.ico' ))))
@@ -871,7 +901,7 @@ def main(self):
871
901
self .ui .Label_Donate_Text .setText (QCA .translate ('MainWindow' , "赞助作者" ))
872
902
Function_SetURL (
873
903
button = self .ui .Button_Donate ,
874
- url = "https://ko-fi.com/spr_aachen " ,
904
+ url = "https://afdian.tv/a/Spr_Aachen/plan " ,
875
905
buttonTooltip = "Click to buy author a coffee"
876
906
)
877
907
@@ -1301,7 +1331,7 @@ def main(self):
1301
1331
subPage_process .addChkOutputSideBtn (
1302
1332
outputRootEdit = self .ui .LineEdit_Process_OutputRoot ,
1303
1333
)
1304
- self .task_audioProcessing = Execute_Audio_Processing (coreDir )
1334
+ self .task_audioProcessing = Execute_Audio_Processing (coreDir , logPath )
1305
1335
subPage_process .setExecutor (
1306
1336
consoleWidget = self .ui .Frame_Console ,
1307
1337
executeMethod = self .task_audioProcessing .execute ,
@@ -1539,7 +1569,7 @@ def EditVPRResult():
1539
1569
EditVPRResult
1540
1570
]
1541
1571
)
1542
- self .task_voiceIdentifying_vpr = Execute_Voice_Identifying_VPR (coreDir )
1572
+ self .task_voiceIdentifying_vpr = Execute_Voice_Identifying_VPR (coreDir , logPath )
1543
1573
subPage_VPR .setExecutor (
1544
1574
consoleWidget = self .ui .Frame_Console ,
1545
1575
executeMethod = self .task_voiceIdentifying_vpr .execute ,
@@ -1675,7 +1705,7 @@ def EditVPRResult():
1675
1705
subPage_ASR .addChkOutputSideBtn (
1676
1706
outputRootEdit = self .ui .LineEdit_ASR_Whisper_OutputRoot
1677
1707
)
1678
- self .task_voiceTranscribing_whisper = Execute_Voice_Transcribing_Whisper (coreDir )
1708
+ self .task_voiceTranscribing_whisper = Execute_Voice_Transcribing_Whisper (coreDir , logPath )
1679
1709
subPage_ASR .setExecutor (
1680
1710
consoleWidget = self .ui .Frame_Console ,
1681
1711
executeMethod = self .task_voiceTranscribing_whisper .execute ,
@@ -1817,7 +1847,7 @@ def EditVPRResult():
1817
1847
subPage_dataset_GPTSoVITS .addChkOutputSideBtn (
1818
1848
outputRootEdit = self .ui .LineEdit_DAT_GPTSoVITS_OutputRoot
1819
1849
)
1820
- self .task_datasetCreating_gptsovits = Execute_Dataset_Creating_GPTSoVITS (coreDir )
1850
+ self .task_datasetCreating_gptsovits = Execute_Dataset_Creating_GPTSoVITS (coreDir , logPath )
1821
1851
subPage_dataset_GPTSoVITS .setExecutor (
1822
1852
consoleWidget = self .ui .Frame_Console ,
1823
1853
executeMethod = self .task_datasetCreating_gptsovits .execute ,
@@ -2007,7 +2037,7 @@ def EditVPRResult():
2007
2037
subPage_dataset_VITS .addChkOutputSideBtn (
2008
2038
outputRootEdit = self .ui .LineEdit_DAT_VITS_OutputRoot
2009
2039
)
2010
- self .task_datasetCreating_vits = Execute_Dataset_Creating_VITS (coreDir )
2040
+ self .task_datasetCreating_vits = Execute_Dataset_Creating_VITS (coreDir , logPath )
2011
2041
subPage_dataset_VITS .setExecutor (
2012
2042
consoleWidget = self .ui .Frame_Console ,
2013
2043
executeMethod = self .task_datasetCreating_vits .execute ,
@@ -2263,7 +2293,7 @@ def EditVPRResult():
2263
2293
)
2264
2294
]
2265
2295
)
2266
- self .task_voiceTraining_gptsovits = Execute_Voice_Training_GPTSoVITS (coreDir )
2296
+ self .task_voiceTraining_gptsovits = Execute_Voice_Training_GPTSoVITS (coreDir , logPath )
2267
2297
subPage_train_gptsovits .setExecutor (
2268
2298
consoleWidget = self .ui .Frame_Console ,
2269
2299
executeMethod = self .task_voiceTraining_gptsovits .execute ,
@@ -2505,7 +2535,7 @@ def EditVPRResult():
2505
2535
)
2506
2536
]
2507
2537
)
2508
- self .task_voiceTraining_vits = Execute_Voice_Training_VITS (coreDir )
2538
+ self .task_voiceTraining_vits = Execute_Voice_Training_VITS (coreDir , logPath )
2509
2539
subPage_train_VITS .setExecutor (
2510
2540
consoleWidget = self .ui .Frame_Console ,
2511
2541
executeMethod = self .task_voiceTraining_vits .execute ,
@@ -2722,7 +2752,7 @@ def EditVPRResult():
2722
2752
)
2723
2753
]
2724
2754
)
2725
- self .task_voiceConverting_gptsovits = Execute_Voice_Converting_GPTSoVITS (coreDir )
2755
+ self .task_voiceConverting_gptsovits = Execute_Voice_Converting_GPTSoVITS (coreDir , logPath )
2726
2756
subPage_tts_gptsovits .setExecutor (
2727
2757
consoleWidget = self .ui .Frame_Console ,
2728
2758
executeMethod = self .task_voiceConverting_gptsovits .execute ,
@@ -2876,7 +2906,7 @@ def EditVPRResult():
2876
2906
)
2877
2907
]
2878
2908
)
2879
- self .task_voiceConverting_vits = Execute_Voice_Converting_VITS (coreDir )
2909
+ self .task_voiceConverting_vits = Execute_Voice_Converting_VITS (coreDir , logPath )
2880
2910
subPage_TTS_VITS .setExecutor (
2881
2911
consoleWidget = self .ui .Frame_Console ,
2882
2912
executeMethod = self .task_voiceConverting_vits .execute ,
0 commit comments