|
|
@ -31,6 +31,10 @@ import subprocess |
|
|
|
import time |
|
|
|
import cherrypy |
|
|
|
from threading import RLock, Lock, Condition, Thread |
|
|
|
try: |
|
|
|
import sleepless |
|
|
|
except ImportError: |
|
|
|
sleepless = None |
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
|
|
# Determine platform flags |
|
|
@ -345,11 +349,6 @@ def start(): |
|
|
|
logging.debug('Starting urlgrabber') |
|
|
|
URLGrabber.do.start() |
|
|
|
|
|
|
|
if DARWIN_ML: |
|
|
|
logging.debug('Starting OSX keep-awake service') |
|
|
|
osxmenu.OsxAwake() |
|
|
|
osxmenu.OsxAwake.do.start() |
|
|
|
|
|
|
|
|
|
|
|
@synchronized(INIT_LOCK) |
|
|
|
def halt(): |
|
|
@ -409,9 +408,6 @@ def halt(): |
|
|
|
except: |
|
|
|
logging.error('Fatal error at saving state', exc_info=True) |
|
|
|
|
|
|
|
if DARWIN_ML: |
|
|
|
osxmenu.OsxAwake.do.stop() |
|
|
|
|
|
|
|
|
|
|
|
# The Scheduler cannot be stopped when the stop was scheduled. |
|
|
|
# Since all warm-restarts have been removed, it's not longer |
|
|
@ -764,16 +760,21 @@ def empty_queues(): |
|
|
|
|
|
|
|
|
|
|
|
def keep_awake(): |
|
|
|
""" If we still have work to do, keep Windows system awake |
|
|
|
""" If we still have work to do, keep Windows/OSX system awake |
|
|
|
""" |
|
|
|
if KERNEL32 or DARWIN_ML: |
|
|
|
if not sabnzbd.downloader.Downloader.do.paused: |
|
|
|
if (not PostProcessor.do.empty()) or not NzbQueue.do.is_empty(): |
|
|
|
if KERNEL32: |
|
|
|
# set ES_SYSTEM_REQUIRED |
|
|
|
KERNEL32.SetThreadExecutionState(ctypes.c_int(0x00000001)) |
|
|
|
else: |
|
|
|
osxmenu.OsxAwake.do.stay_awake = True |
|
|
|
if KERNEL32 or sleepless: |
|
|
|
if sabnzbd.cfg.keep_awake(): |
|
|
|
awake = False |
|
|
|
if not sabnzbd.downloader.Downloader.do.paused: |
|
|
|
if (not PostProcessor.do.empty()) or not NzbQueue.do.is_empty(): |
|
|
|
awake = True |
|
|
|
if KERNEL32: |
|
|
|
# set ES_SYSTEM_REQUIRED |
|
|
|
KERNEL32.SetThreadExecutionState(ctypes.c_int(0x00000001)) |
|
|
|
else: |
|
|
|
sleepless.keep_awake() |
|
|
|
if not awake and sleepless: |
|
|
|
sleepless.allow_sleep() |
|
|
|
|
|
|
|
|
|
|
|
def CheckFreeSpace(): |
|
|
|