Restart TWBlue gracefully

This commit is contained in:
Manuel Cortez 2020-05-29 09:49:57 -05:00
parent 6bc63d79ff
commit 084fa1894c

View File

@ -1,6 +1,7 @@
# -*- coding: cp1252
from __future__ import unicode_literals
import sys, os
import application
def restart_program():
""" Function that restarts the application if is executed."""
@ -9,4 +10,7 @@ def restart_program():
args.insert(0, sys.executable)
if sys.platform == 'win32':
args = ['"%s"' % arg for arg in args]
pidpath = os.path.join(os.getenv("temp"), "{}.pid".format(application.name))
if os.path.exists(pidpath):
os.remove(pidpath)
os.execv(sys.executable, args)