diff --git a/core/__init__.py b/core/__init__.py index 7dcd4fd9..593c4a5a 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -63,6 +63,7 @@ from core.utils import ( remove_dir, remove_read_only, remove_torrent, + restart, resume_torrent, sanitize_name, update_download_info_status, @@ -863,23 +864,3 @@ def initialize(section=None): # finished initalizing return True - - -def restart(): - install_type = version_check.CheckVersion().install_type - - status = 0 - popen_list = [] - - if install_type in ('git', 'source'): - popen_list = [sys.executable, APP_FILENAME] - - if popen_list: - popen_list += SYS_ARGV - logger.log(u'Restarting nzbToMedia with {args}'.format(args=popen_list)) - logger.close() - p = subprocess.Popen(popen_list, cwd=os.getcwd()) - p.wait() - status = p.returncode - - os._exit(status) diff --git a/core/utils/__init__.py b/core/utils/__init__.py index 99bb0376..0083fbbd 100644 --- a/core/utils/__init__.py +++ b/core/utils/__init__.py @@ -43,7 +43,7 @@ from core.utils.paths import ( remove_empty_folders, remove_read_only, ) -from core.utils.processes import RunningProcess +from core.utils.processes import RunningProcess, restart from core.utils.subtitles import import_subs from core.utils.torrents import create_torrent_class, pause_torrent, remove_torrent, resume_torrent diff --git a/core/utils/processes.py b/core/utils/processes.py index 6513a12c..6edcfa44 100644 --- a/core/utils/processes.py +++ b/core/utils/processes.py @@ -1,7 +1,10 @@ import os import socket +import subprocess +import sys import core +from core import logger, version_check, APP_FILENAME, SYS_ARGV if os.name == 'nt': from win32event import CreateMutex @@ -90,3 +93,23 @@ if os.name == 'nt': RunningProcess = WindowsProcess else: RunningProcess = PosixProcess + + +def restart(): + install_type = version_check.CheckVersion().install_type + + status = 0 + popen_list = [] + + if install_type in ('git', 'source'): + popen_list = [sys.executable, APP_FILENAME] + + if popen_list: + popen_list += SYS_ARGV + logger.log(u'Restarting nzbToMedia with {args}'.format(args=popen_list)) + logger.close() + p = subprocess.Popen(popen_list, cwd=os.getcwd()) + p.wait() + status = p.returncode + + os._exit(status)