예제 #1
0
def _main():
    util.DEBUG_LOG('[ STARTED: {0} -------------------------------------------------------------------- ]'.format(util.ADDON.getAddonInfo('version')))
    util.DEBUG_LOG('USER-AGENT: {0}'.format(plex.defaultUserAgent()))
    background.setSplash()

    try:
        while not xbmc.abortRequested:
            if plex.init():
                background.setSplash(False)
                while not xbmc.abortRequested:
                    if (
                        not plexapp.ACCOUNT.isOffline and not
                        plexapp.ACCOUNT.isAuthenticated and
                        (len(plexapp.ACCOUNT.homeUsers) > 1 or plexapp.ACCOUNT.isProtected)

                    ):
                        result = userselect.start()
                        if not result:
                            return
                        elif result == 'signout':
                            signout()
                            break
                        elif result == 'signin':
                            break
                        util.DEBUG_LOG('Main: User selected')

                    try:
                        done = plex.CallbackEvent(plexapp.APP, 'change:selectedServer', timeout=11)
                        if not plexapp.SERVERMANAGER.selectedServer:
                            util.DEBUG_LOG('Main: Waiting for selected server...')
                            try:
                                background.setBusy()
                                done.wait()
                            finally:
                                background.setBusy(False)

                        util.DEBUG_LOG('Main: STARTING WITH SERVER: {0}'.format(plexapp.SERVERMANAGER.selectedServer))

                        windowutils.HOME = home.HomeWindow.open()
                        util.CRON.cancelReceiver(windowutils.HOME)

                        if not windowutils.HOME.closeOption:
                            return

                        closeOption = windowutils.HOME.closeOption

                        windowutils.shutdownHome()

                        if closeOption == 'signout':
                            signout()
                            break
                        elif closeOption == 'switch':
                            plexapp.ACCOUNT.isAuthenticated = False
                    finally:
                        windowutils.shutdownHome()
                        BACKGROUND.activate()
                        gc.collect(2)

            else:
                break
    except:
        util.ERROR()
    finally:
        util.DEBUG_LOG('Main: SHUTTING DOWN...')
        background.setShutdown()
        player.shutdown()
        plexapp.APP.preShutdown()
        util.CRON.stop()
        backgroundthread.BGThreader.shutdown()
        plexapp.APP.shutdown()
        waitForThreads()
        background.setBusy(False)
        background.setSplash(False)

        util.DEBUG_LOG('FINISHED')

        from windows import kodigui
        kodigui.MONITOR = None
        util.shutdown()

        gc.collect(2)
예제 #2
0
    recorder.start()

    webinterface.WebInterfaceHandler.cmd_q = cmd_q

    logger.info("Starting Web Server\n\n")
    web_th = webinterface.start()

    while True:
        request = cmd_q.get()
        if request.cmd == Command.CMD_REBOOT:
            recorder.stop()
            util.reboot()
            request.done()
        elif request.cmd == Command.CMD_SHUTDOWN:
            recorder.stop()
            util.shutdown()
            request.done()
        elif request.cmd == Command.CMD_STOP_REC:
            recorder.stop()
            request.done()
        elif request.cmd == Command.CMD_START_REC:
            recorder.start()
            request.done()
        elif request.cmd == Command.CMD_ROTATE:
            recorder.queue_commands(request)
        elif request.cmd == Command.CMD_SET_SYS_DATETIME:
            util.set_system_datetime(request.data)
            request.done()

except Exception as e:
    logger.error(e)
예제 #3
0
def shutdown():
	return util.shutdown()
예제 #4
0
def shutdown():
    return util.shutdown()
예제 #5
0
def shutdown():
    syslog.syslog('received shutdown request')
    return util.shutdown()