Execute shutdown function before running update to avoid segfault on linux
This commit is contained in:
parent
0b04176f18
commit
743463dce9
1 changed files with 16 additions and 10 deletions
26
zeronet.py
26
zeronet.py
|
@ -1,6 +1,4 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# Included modules
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -35,12 +33,19 @@ def main():
|
||||||
|
|
||||||
if main and (main.update_after_shutdown or main.restart_after_shutdown): # Updater
|
if main and (main.update_after_shutdown or main.restart_after_shutdown): # Updater
|
||||||
if main.update_after_shutdown:
|
if main.update_after_shutdown:
|
||||||
|
print("Shutting down...")
|
||||||
|
prepareShutdown()
|
||||||
import update
|
import update
|
||||||
|
print("Updating...")
|
||||||
update.update()
|
update.update()
|
||||||
restart()
|
|
||||||
else:
|
|
||||||
print("Restarting...")
|
print("Restarting...")
|
||||||
restart()
|
restart()
|
||||||
|
else:
|
||||||
|
print("Shutting down...")
|
||||||
|
prepareShutdown()
|
||||||
|
print("Restarting...")
|
||||||
|
restart()
|
||||||
|
|
||||||
|
|
||||||
def displayErrorMessage(err, error_log_path):
|
def displayErrorMessage(err, error_log_path):
|
||||||
import ctypes
|
import ctypes
|
||||||
|
@ -64,11 +69,12 @@ def displayErrorMessage(err, error_log_path):
|
||||||
if res in [ID_YES, ID_NO]:
|
if res in [ID_YES, ID_NO]:
|
||||||
subprocess.Popen(['notepad.exe', error_log_path])
|
subprocess.Popen(['notepad.exe', error_log_path])
|
||||||
|
|
||||||
|
def prepareShutdown():
|
||||||
|
import atexit
|
||||||
|
atexit._run_exitfuncs()
|
||||||
|
|
||||||
def restart():
|
# Close log files
|
||||||
if "main" in sys.modules:
|
if "main" in sys.modules:
|
||||||
import atexit
|
|
||||||
# Close log files
|
|
||||||
logger = sys.modules["main"].logging.getLogger()
|
logger = sys.modules["main"].logging.getLogger()
|
||||||
|
|
||||||
for handler in logger.handlers[:]:
|
for handler in logger.handlers[:]:
|
||||||
|
@ -76,10 +82,10 @@ def restart():
|
||||||
handler.close()
|
handler.close()
|
||||||
logger.removeHandler(handler)
|
logger.removeHandler(handler)
|
||||||
|
|
||||||
atexit._run_exitfuncs()
|
import time
|
||||||
import time
|
time.sleep(1) # Wait files to close
|
||||||
time.sleep(1) # Wait files to close
|
|
||||||
|
|
||||||
|
def restart():
|
||||||
args = sys.argv[:]
|
args = sys.argv[:]
|
||||||
|
|
||||||
sys.executable = sys.executable.replace(".pkg", "") # Frozen mac fix
|
sys.executable = sys.executable.replace(".pkg", "") # Frozen mac fix
|
||||||
|
|
Loading…
Reference in a new issue