diff --git a/batch/restart.bat b/batch/restart.bat index e02b64a0..b6e9b03b 100644 --- a/batch/restart.bat +++ b/batch/restart.bat @@ -1,8 +1,9 @@ @if not "%~0"=="%~dp0.\%~nx0" start /min cmd /c,"%~dp0.\%~nx0" %* & goto :eof set name=%1 -set path=%~dp0 +set local_path=%~dp0 taskkill /im %name% /F - -START "" %path%/%name% \ No newline at end of file +ping -n 2 127.0.0.1 > nul +START "" %local_path%%name% +del /f "%~dp0%~nx0" \ No newline at end of file diff --git a/batch/update.bat b/batch/update.bat index 4bc2e679..e0e83855 100644 --- a/batch/update.bat +++ b/batch/update.bat @@ -4,17 +4,17 @@ set exe_name=%1 set folder_name=%2 set folder_tmp=%3 set restart=%4 -set path=%~dp0 +set local_path=%~dp0 taskkill /im %exe_name% /F ping -n 2 127.0.0.1 > nul -del /f %exe_name% -rmdir /s /q %folder_name% -move /Y %exe_tmp_name%\* .\ -rmdir /s /q %exe_tmp_name% +del /f %local_path%%exe_name% +rmdir /s /q %local_path%%folder_name% +xcopy %local_path%%folder_tmp% %local_path% /E /I +rmdir /s /q %local_path%%folder_tmp% if %restart% == True ( - START "" %path%/%exe_name% + START "" %local_path%%exe_name% ) - +pause del /f "%~dp0%~nx0" \ No newline at end of file diff --git a/model.py b/model.py index f79c4dfc..ab5f49ce 100644 --- a/model.py +++ b/model.py @@ -3,6 +3,7 @@ from zipfile import ZipFile from subprocess import Popen, PIPE from os import makedirs as os_makedirs from os import path as os_path +from os import remove as os_remove from shutil import rmtree, move from datetime import datetime from logging import getLogger, FileHandler, Formatter, INFO @@ -284,6 +285,7 @@ class Model: file.write(chunk) with ZipFile(os_path.join(current_directory, tmp_directory_name, filename)) as zf: zf.extractall(os_path.join(current_directory, tmp_directory_name)) + os_remove(os_path.join(current_directory, tmp_directory_name, filename)) move(os_path.join(current_directory, folder_name, "batch", batch_name), os_path.join(current_directory, batch_name)) command = [os_path.join(current_directory, batch_name), program_name, folder_name, tmp_directory_name, str(restart)] Popen(command, cwd=current_directory) @@ -297,8 +299,8 @@ class Model: folder_name = '_internal' batch_name = 'restart.bat' current_directory = config.LOCAL_PATH - - command = [os_path.join(current_directory, folder_name, "batch", batch_name), program_name] + move(os_path.join(current_directory, folder_name, "batch", batch_name), os_path.join(current_directory, batch_name)) + command = [os_path.join(current_directory, batch_name), program_name] Popen(command, cwd=current_directory) @staticmethod