예제 #1
0
def keep_awake():
    """ If we still have work to do, keep Windows/OSX system awake """
    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(u'SABnzbd is busy downloading and/or post-processing')
            if not awake and sleepless:
                sleepless.allow_sleep()
예제 #2
0
def keep_awake():
    """ If we still have work to do, keep Windows/OSX system awake """
    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(u'SABnzbd is busy downloading and/or post-processing')
            if not awake and sleepless:
                sleepless.allow_sleep()
예제 #3
0
#!/usr/bin/env python

import sleepless
import sys
import time
from subprocess import Popen, PIPE


def show_state():
    output = Popen(["pmset", "-g", "assertions"], stdout=PIPE).communicate()[0]
    for line in output.split('\n'):
        if 'SABnzbd' in line:
            return line
    return 'Nothing'


msg = u"SABnzbd is r\xe8nning"
print msg

print show_state()
print "Starting assertion"
for n in xrange(6):
    sleepless.keep_awake(msg)
    time.sleep(1)
    print show_state()
print "Stopping assertion"
sleepless.allow_sleep()
print show_state()
print "Done"