示例#1
0
def checkAce():
    if AceConfig.acespawn and not isRunning(AceProxy.ace):
       if AceProxy.clientcounter.idleAce: AceProxy.clientcounter.idleAce.ShutdownAce()
       if hasattr(AceProxy, 'ace'): del AceProxy.ace
       if spawnAce():
          logger.error('Ace Stream died, respawned with pid %s' % AceProxy.ace.pid)
          # refresh the acestream.port file for Windows only after full loading...
          if AceConfig.osplatform == 'Windows': detectPort()
          else: gevent.sleep(AceConfig.acestartuptimeout)
          # Creating ClientCounter
          AceProxy.clientcounter = ClientCounter()
       else:
          logger.error("Can't spawn Ace Stream!")
示例#2
0
                 AceConfig.httpport)
    sys.exit(1)

# Dropping root privileges if needed
if AceConfig.osplatform != 'Windows' and AceConfig.aceproxyuser and os.getuid(
) == 0:
    if drop_privileges(AceConfig.aceproxyuser):
        logger.info('Dropped privileges to user %s' % AceConfig.aceproxyuser)
    else:
        logger.error('Cannot drop privileges to user %s' %
                     AceConfig.aceproxyuser)
        sys.exit(1)

# Creating ClientCounter
AceProxy.pool = Pool()
AceProxy.clientcounter = ClientCounter()
#### AceEngine startup
AceProxy.ace = findProcess('ace_engine.exe' if AceConfig.osplatform ==
                           'Windows' else os.path.basename(AceConfig.acecmd))
if not AceProxy.ace and AceConfig.acespawn:
    if spawnAce():
        logger.info('Local AceStream engine spawned with pid %s' %
                    AceProxy.ace.pid)
        schedule(AceConfig.acestartuptimeout,
                 checkAce)  # Start AceEngine alive watchdog
elif AceProxy.ace:
    AceProxy.ace = psutil.Process(AceProxy.ace)
    logger.info('Local AceStream engine found with pid %s' % AceProxy.ace.pid)

# If AceEngine started (found) localy
if AceProxy.ace:
示例#3
0
server = HTTPServer((AceConfig.httphost, AceConfig.httpport), HTTPHandler)
logger = logging.getLogger('HTTP')

# Dropping root privileges if needed
if AceConfig.osplatform != 'Windows' and AceConfig.aceproxyuser and os.getuid(
) == 0:
    if drop_privileges(AceConfig.aceproxyuser):
        logger.info("Dropped privileges to user " + AceConfig.aceproxyuser)
    else:
        logger.error("Cannot drop privileges to user " +
                     AceConfig.aceproxyuser)
        sys.exit(1)

# Creating ClientCounter
AceStuff.clientcounter = ClientCounter()

if AceConfig.vlcspawn or AceConfig.acespawn:
    DEVNULL = open(os.devnull, 'wb')


# Spawning procedures
def spawnVLC(cmd, delay=0):
    try:
        if AceConfig.osplatform == 'Windows' and AceConfig.vlcuseaceplayer:
            import _winreg
            import os.path
            reg = _winreg.ConnectRegistry(None, _winreg.HKEY_CURRENT_USER)
            try:
                key = _winreg.OpenKey(reg, 'Software\AceStream')
            except: