Browse Source

MacOS running from sources can use regular restart-path

pull/752/head
Safihre 9 years ago
parent
commit
f093dbef7a
  1. 29
      SABnzbd.py
  2. 2
      sabnzbd/__init__.py

29
SABnzbd.py

@ -1580,24 +1580,17 @@ def main():
sys.argv = sabnzbd.RESTART_ARGS
os.chdir(org_dir)
if sabnzbd.DARWIN:
# When executing from sources on osx, after a restart, process is detached from console
# If OSX frozen restart of app instead of embedded python
if getattr(sys, 'frozen', None) == 'macosx_app':
# [[NSProcessInfo processInfo] processIdentifier]]
# logging.info("%s" % (NSProcessInfo.processInfo().processIdentifier()))
my_pid = os.getpid()
my_name = sabnzbd.MY_FULLNAME.replace('/Contents/MacOS/SABnzbd', '')
my_args = ' '.join(sys.argv[1:])
cmd = 'kill -9 %s && open "%s" --args %s' % (my_pid, my_name, my_args)
logging.info('Launching: ', cmd)
os.system(cmd)
else:
args = sys.argv[:]
args.insert(0, sys.executable)
pid = os.fork()
if pid == 0:
os.execv(sys.executable, args)
# If OSX frozen restart of app instead of embedded python
if getattr(sys, 'frozen', None) == 'macosx_app':
# [[NSProcessInfo processInfo] processIdentifier]]
# logging.info("%s" % (NSProcessInfo.processInfo().processIdentifier()))
my_pid = os.getpid()
my_name = sabnzbd.MY_FULLNAME.replace('/Contents/MacOS/SABnzbd', '')
my_args = ' '.join(sys.argv[1:])
cmd = 'kill -9 %s && open "%s" --args %s' % (my_pid, my_name, my_args)
logging.info('Launching: ', cmd)
os.system(cmd)
elif sabnzbd.WIN_SERVICE and mail:
logging.info('Asking the SABHelper service for a restart')
mail.send('restart')

2
sabnzbd/__init__.py

@ -470,7 +470,7 @@ def trigger_restart():
del_connection_info()
# Leave the harder restarts to the polling in SABnzbd.py
if sabnzbd.WIN_SERVICE or sabnzbd.DARWIN:
if sabnzbd.WIN_SERVICE or getattr(sys, 'frozen', None) == 'macosx_app':
sabnzbd.TRIGGER_RESTART = True
else:
# Do the restart right now

Loading…
Cancel
Save