Пример #1
0
    def run(self):
        global restart, startPort, forceUpdate, noLaunch, web_options

        # Use this PID for everything
        sickbeard.PID = os.getpid()

        try:
            webserveInit.initWebServer(web_options)
        except IOError:
            logger.log(u"Unable to start web server, is something else running on port %d?" % startPort, logger.ERROR)
            if sickbeard.LAUNCH_BROWSER and not sickbeard.DAEMON:
                logger.log(u"Launching browser and exiting", logger.ERROR)
                sickbeard.launchBrowser(startPort)
            sys.exit()

        # Fire up all our threads
        sickbeard.start()

        # Launch browser if we're supposed to
        if sickbeard.LAUNCH_BROWSER and not noLaunch:
            sickbeard.launchBrowser(startPort)

        if sickbeard.LAUNCH_BROWSER and not (noLaunch or sickbeard.DAEMON or restart):
            sickbeard.launchBrowser(startPort)

        # reset this if sickrage was restarted
        restart = False

        # start IO loop
        IOLoop.current().start()

        # close IO loop
        IOLoop.current().close(True)

        # stop all tasks
        sickbeard.halt()

        # save all shows to DB
        sickbeard.saveAll()
Пример #2
0
def main():

	# use this pid for everything
	sickbeard.PID = os.getpid()

	# do some preliminary stuff
	sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(sys.argv[0]))
	sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
	sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)
	sickbeard.MY_ARGS = sys.argv[1:]

	sickbeard.CONFIG_FILE = os.path.join(sickbeard.PROG_DIR, "config.ini")

	# need console logging for SickBeard.py and SickBeard-console.exe
	consoleLogging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find('-console') > 0)

	# rename the main thread
	threading.currentThread().name = "MAIN"

	try:
		opts, args = getopt.getopt(sys.argv[1:], "qfp:", ['quiet', 'force-update', 'port=', 'tvbinz'])
	except getopt.GetoptError:
		print "Available options: --quiet, --forceupdate, --port"
		sys.exit()

	forceUpdate = False
	forcedPort = None

	for o, a in opts:
		# for now we'll just silence the logging
		if (o in ('-q', '--quiet')):
			consoleLogging = False
		# for now we'll just silence the logging
		if (o in ('--tvbinz')):
			sickbeard.SHOW_TVBINZ = True

		# should we update right away?
		if (o in ('-f', '--forceupdate')):
			forceUpdate = True

		# should we update right away?
		if (o in ('-p', '--port')):
			forcedPort = int(a)

	if consoleLogging:
		print "Starting up Sick Beard "+SICKBEARD_VERSION+" from " + sickbeard.CONFIG_FILE

	# load the config and publish it to the sickbeard package
	if not os.path.isfile(sickbeard.CONFIG_FILE):
		logger.log(u"Unable to find config.ini, all settings will be default", logger.ERROR)

	sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

	# initialize the config and our threads
	sickbeard.initialize(consoleLogging=consoleLogging)

	sickbeard.showList = []

	if forcedPort:
		logger.log(u"Forcing web server to port "+str(forcedPort))
		startPort = forcedPort
	else:
		startPort = sickbeard.WEB_PORT

	logger.log(u"Starting Sick Beard on http://localhost:"+str(startPort))

	if sickbeard.WEB_LOG:
		log_dir = sickbeard.LOG_DIR
	else:
		log_dir = None

	# sickbeard.WEB_HOST is available as a configuration value in various
	# places but is not configurable. It is supported here for historic
	# reasons.
	if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
		webhost = sickbeard.WEB_HOST
	else:
		if sickbeard.WEB_IPV6:
			webhost = '::'
		else:
			webhost = '0.0.0.0'

	try:
		initWebServer({
		        'port':      startPort,
		        'host':      webhost,
		        'data_root': os.path.join(sickbeard.PROG_DIR, 'data'),
		        'web_root':  sickbeard.WEB_ROOT,
		        'log_dir':   log_dir,
		        'username':  sickbeard.WEB_USERNAME,
		        'password':  sickbeard.WEB_PASSWORD,
		})
	except IOError:
		logger.log(u"Unable to start web server, is something else running on port %d?" % startPort, logger.ERROR)
		if sickbeard.LAUNCH_BROWSER:
			logger.log(u"Launching browser and exiting", logger.ERROR)
			sickbeard.launchBrowser(startPort)
		sys.exit()

	# build from the DB to start with
	logger.log(u"Loading initial show list")
	loadShowsFromDB()

	# set up the lists
	sickbeard.updateAiringList()
	sickbeard.updateComingList()

	# fire up all our threads
	sickbeard.start()

	# launch browser if we're supposed to
	if sickbeard.LAUNCH_BROWSER:
		sickbeard.launchBrowser(startPort)

	# start an update if we're supposed to
	if forceUpdate:
		sickbeard.showUpdateScheduler.action.run(force=True)

	# stay alive while my threads do the work
	while (True):

		time.sleep(1)

	return
Пример #3
0
    if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
        webhost = sickbeard.WEB_HOST
    else:
        if sickbeard.WEB_IPV6:
            webhost = '::'
        else:
            webhost = '0.0.0.0'

    logger.log(u"Starting Sick Beard on http://" + str(webhost) + ":" + str(startPort) + "/")

    try:
        initWebServer({
                'port': startPort,
                'host': webhost,
                'data_root': os.path.join(sickbeard.PROG_DIR, 'data'),
                'web_root': sickbeard.WEB_ROOT,
                'log_dir': log_dir,
                'username': sickbeard.WEB_USERNAME,
                'password': sickbeard.WEB_PASSWORD,
        })
    except IOError:
        logger.log(u"Unable to start web server, is something else running on port %d?" % startPort, logger.ERROR)
        if sickbeard.LAUNCH_BROWSER:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(startPort)
        sys.exit()

    # build from the DB to start with
    logger.log(u"Loading initial show list")
    loadShowsFromDB()
Пример #4
0
def main():

    # do some preliminary stuff
    sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(__file__))
    sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
    sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)
    sickbeard.MY_ARGS = sys.argv[1:]

    try:
        locale.setlocale(locale.LC_ALL, "")
    except (locale.Error, IOError):
        pass
    sickbeard.SYS_ENCODING = locale.getpreferredencoding()

    # for OSes that are poorly configured I'll just force UTF-8
    if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING in ("ANSI_X3.4-1968", "US-ASCII"):
        sickbeard.SYS_ENCODING = "UTF-8"

    sickbeard.CONFIG_FILE = os.path.join(sickbeard.PROG_DIR, "config.ini")

    # need console logging for SickBeard.py and SickBeard-console.exe
    consoleLogging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find("-console") > 0)

    # rename the main thread
    threading.currentThread().name = "MAIN"

    try:
        opts, args = getopt.getopt(sys.argv[1:], "qfdp:", ["quiet", "forceupdate", "daemon", "port=", "tvbinz"])
    except getopt.GetoptError:
        print "Available options: --quiet, --forceupdate, --port, --daemon"
        sys.exit()

    forceUpdate = False
    forcedPort = None

    for o, a in opts:
        # for now we'll just silence the logging
        if o in ("-q", "--quiet"):
            consoleLogging = False
        # for now we'll just silence the logging
        if o in ("--tvbinz"):
            sickbeard.SHOW_TVBINZ = True

        # should we update right away?
        if o in ("-f", "--forceupdate"):
            forceUpdate = True

        # use a different port
        if o in ("-p", "--port"):
            forcedPort = int(a)

        # Run as a daemon
        if o in ("-d", "--daemon"):
            if sys.platform == "win32":
                print "Daemonize not supported under Windows, starting normally"
            else:
                consoleLogging = False
                sickbeard.DAEMON = True

    if consoleLogging:
        print "Starting up Sick Beard " + SICKBEARD_VERSION + " from " + sickbeard.CONFIG_FILE

    # load the config and publish it to the sickbeard package
    if not os.path.isfile(sickbeard.CONFIG_FILE):
        logger.log(u"Unable to find config.ini, all settings will be default", logger.ERROR)

    sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

    # initialize the config and our threads
    sickbeard.initialize(consoleLogging=consoleLogging)

    sickbeard.showList = []

    if sickbeard.DAEMON:
        daemonize()

    # use this pid for everything
    sickbeard.PID = os.getpid()

    if forcedPort:
        logger.log(u"Forcing web server to port " + str(forcedPort))
        startPort = forcedPort
    else:
        startPort = sickbeard.WEB_PORT

    logger.log(u"Starting Sick Beard on http://localhost:" + str(startPort))

    if sickbeard.WEB_LOG:
        log_dir = sickbeard.LOG_DIR
    else:
        log_dir = None

    # sickbeard.WEB_HOST is available as a configuration value in various
    # places but is not configurable. It is supported here for historic
    # reasons.
    if sickbeard.WEB_HOST and sickbeard.WEB_HOST != "0.0.0.0":
        webhost = sickbeard.WEB_HOST
    else:
        if sickbeard.WEB_IPV6:
            webhost = "::"
        else:
            webhost = "0.0.0.0"

    try:
        initWebServer(
            {
                "port": startPort,
                "host": webhost,
                "data_root": os.path.join(sickbeard.PROG_DIR, "data"),
                "web_root": sickbeard.WEB_ROOT,
                "log_dir": log_dir,
                "username": sickbeard.WEB_USERNAME,
                "password": sickbeard.WEB_PASSWORD,
            }
        )
    except IOError:
        logger.log(u"Unable to start web server, is something else running on port %d?" % startPort, logger.ERROR)
        if sickbeard.LAUNCH_BROWSER:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(startPort)
        sys.exit()

    # build from the DB to start with
    logger.log(u"Loading initial show list")
    loadShowsFromDB()

    # fire up all our threads
    sickbeard.start()

    # launch browser if we're supposed to
    if sickbeard.LAUNCH_BROWSER:
        sickbeard.launchBrowser(startPort)

    # start an update if we're supposed to
    if forceUpdate:
        sickbeard.showUpdateScheduler.action.run(force=True)

    # stay alive while my threads do the work
    while True:

        time.sleep(1)

    return
Пример #5
0
    if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
        webhost = sickbeard.WEB_HOST
    else:
        if sickbeard.WEB_IPV6:
            webhost = '::'
        else:
            webhost = '0.0.0.0'

    try:
        initWebServer({
            'port': startPort,
            'host': webhost,
            'data_root': os.path.join(sickbeard.PROG_DIR, 'gui/' + sickbeard.GUI_NAME),
            'web_root': sickbeard.WEB_ROOT,
            'log_dir': log_dir,
            'username': sickbeard.WEB_USERNAME,
            'password': sickbeard.WEB_PASSWORD,
            'enable_https': sickbeard.ENABLE_HTTPS,
            'handle_reverse_proxy': sickbeard.HANDLE_REVERSE_PROXY,
            'https_cert': sickbeard.HTTPS_CERT,
            'https_key': sickbeard.HTTPS_KEY,
        })
    except IOError:
        logger.log(u"Unable to start web server, is something else running on port %d?" % startPort, logger.ERROR)
        if sickbeard.LAUNCH_BROWSER and not sickbeard.DAEMON:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(startPort)
        sys.exit()

    # Build from the DB to start with
    logger.log(u"Loading initial show list")
Пример #6
0
def main():

    # do some preliminary stuff
    sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(__file__))
    sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
    sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)
    sickbeard.MY_ARGS = sys.argv[1:]

    try:
        locale.setlocale(locale.LC_ALL, "")
    except (locale.Error, IOError):
        pass
    sickbeard.SYS_ENCODING = locale.getpreferredencoding()
    
    # for OSes that are poorly configured I'll just force UTF-8
    if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII'):
        sickbeard.SYS_ENCODING = 'UTF-8'

    sickbeard.CONFIG_FILE = os.path.join(sickbeard.PROG_DIR, "config.ini")

    # need console logging for SickBeard.py and SickBeard-console.exe
    consoleLogging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find('-console') > 0)

    # rename the main thread
    threading.currentThread().name = "MAIN"

    try:
        opts, args = getopt.getopt(sys.argv[1:], "qfdp:", ['quiet', 'forceupdate', 'daemon', 'port=', 'tvbinz'])
    except getopt.GetoptError:
        print "Available options: --quiet, --forceupdate, --port, --daemon"
        sys.exit()

    forceUpdate = False
    forcedPort = None

    for o, a in opts:
        # for now we'll just silence the logging
        if (o in ('-q', '--quiet')):
            consoleLogging = False
        # for now we'll just silence the logging
        if (o in ('--tvbinz')):
            sickbeard.SHOW_TVBINZ = True

        # should we update right away?
        if (o in ('-f', '--forceupdate')):
            forceUpdate = True

        # use a different port
        if (o in ('-p', '--port')):
            forcedPort = int(a)

        # Run as a daemon
        if (o in ('-d', '--daemon')):
            if sys.platform == 'win32':
                print "Daemonize not supported under Windows, starting normally"
            else:
                consoleLogging = False
                sickbeard.DAEMON = True

    if consoleLogging:
        print "Starting up Sick Beard "+SICKBEARD_VERSION+" from " + sickbeard.CONFIG_FILE

    # load the config and publish it to the sickbeard package
    if not os.path.isfile(sickbeard.CONFIG_FILE):
        logger.log(u"Unable to find config.ini, all settings will be default", logger.ERROR)

    sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

    # initialize the config and our threads
    sickbeard.initialize(consoleLogging=consoleLogging)

    sickbeard.showList = []

    if sickbeard.DAEMON:
        daemonize()
    
    # use this pid for everything
    sickbeard.PID = os.getpid()

    if forcedPort:
        logger.log(u"Forcing web server to port "+str(forcedPort))
        startPort = forcedPort
    else:
        startPort = sickbeard.WEB_PORT

    logger.log(u"Starting Sick Beard on http://localhost:"+str(startPort))

    if sickbeard.WEB_LOG:
        log_dir = sickbeard.LOG_DIR
    else:
        log_dir = None

    # sickbeard.WEB_HOST is available as a configuration value in various
    # places but is not configurable. It is supported here for historic
    # reasons.
    if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
        webhost = sickbeard.WEB_HOST
    else:
        if sickbeard.WEB_IPV6:
            webhost = '::'
        else:
            webhost = '0.0.0.0'

    try:
        initWebServer({
                'port':      startPort,
                'host':      webhost,
                'data_root': os.path.join(sickbeard.PROG_DIR, 'data'),
                'web_root':  sickbeard.WEB_ROOT,
                'log_dir':   log_dir,
                'username':  sickbeard.WEB_USERNAME,
                'password':  sickbeard.WEB_PASSWORD,
        })
    except IOError:
        logger.log(u"Unable to start web server, is something else running on port %d?" % startPort, logger.ERROR)
        if sickbeard.LAUNCH_BROWSER:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(startPort)
        sys.exit()

    # build from the DB to start with
    logger.log(u"Loading initial show list")
    loadShowsFromDB()

    # fire up all our threads
    sickbeard.start()

    # launch browser if we're supposed to
    if sickbeard.LAUNCH_BROWSER:
        sickbeard.launchBrowser(startPort)

    # start an update if we're supposed to
    if forceUpdate:
        sickbeard.showUpdateScheduler.action.run(force=True)

    # stay alive while my threads do the work
    while (True):

        time.sleep(1)

    return
Пример #7
0
def main():

    # do some preliminary stuff
    sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(sys.argv[0]))
    sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
    sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)

    config_file = os.path.join(sickbeard.PROG_DIR, "config.ini")

    # need console logging for SickBeard.py and SickBeard-console.exe
    consoleLogging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find("-console") > 0)

    # rename the main thread
    threading.currentThread().name = "MAIN"

    try:
        opts, args = getopt.getopt(sys.argv[1:], "qfp:", ["quiet", "force-update", "port=", "tvbinz"])
    except getopt.GetoptError:
        print "Available options: --quiet, --forceupdate, --port"
        sys.exit()

    forceUpdate = False
    forcedPort = None

    for o, a in opts:
        # for now we'll just silence the logging
        if o in ("-q", "--quiet"):
            consoleLogging = False
            # for now we'll just silence the logging
        if o in ("--tvbinz"):
            sickbeard.SHOW_TVBINZ = True

            # should we update right away?
        if o in ("-f", "--forceupdate"):
            forceUpdate = True

            # should we update right away?
        if o in ("-p", "--port"):
            forcedPort = int(a)

    if consoleLogging:
        print "Starting up Sick Beard " + SICKBEARD_VERSION + " from " + config_file

        # load the config and publish it to the sickbeard package
    if not os.path.isfile(config_file):
        logger.log("Unable to find config.ini, all settings will be default", logger.ERROR)

    sickbeard.CFG = ConfigObj(config_file)

    # initialize the config and our threads
    sickbeard.initialize(consoleLogging=consoleLogging)

    sickbeard.showList = []

    if forcedPort:
        logger.log("Forcing web server to port " + str(forcedPort))
        startPort = forcedPort
    else:
        startPort = sickbeard.WEB_PORT

    logger.log("Starting Sick Beard on http://localhost:" + str(startPort))

    try:
        initWebServer(
            {
                "port": startPort,
                "data_root": os.path.join(sickbeard.PROG_DIR, "data"),
                "web_root": sickbeard.WEB_ROOT,
                "log_dir": sickbeard.LOG_DIR if sickbeard.WEB_LOG else None,
                "username": sickbeard.WEB_USERNAME,
                "password": sickbeard.WEB_PASSWORD,
            }
        )
    except IOError:
        logger.log(
            "Unable to start web server, is something else running on port %d?" % sickbeard.WEB_PORT, logger.ERROR
        )
        if sickbeard.LAUNCH_BROWSER:
            logger.log("Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser()
        sys.exit()

        # build from the DB to start with
    logger.log("Loading initial show list")
    loadShowsFromDB()

    # set up the lists
    sickbeard.updateAiringList()
    sickbeard.updateComingList()
    sickbeard.updateMissingList()

    # fire up all our threads
    sickbeard.start()

    # launch browser if we're supposed to
    if sickbeard.LAUNCH_BROWSER:
        sickbeard.launchBrowser()

        # start an update if we're supposed to
    if forceUpdate:
        sickbeard.showUpdateScheduler.action.run(force=True)

        # stay alive while my threads do the work
    while True:

        time.sleep(1)

    return
Пример #8
0
        else:
            webhost = '0.0.0.0'

    try:
        initWebServer({
            'port':
            startPort,
            'host':
            webhost,
            'data_root':
            os.path.join(sickbeard.PROG_DIR, 'gui/' + sickbeard.GUI_NAME),
            'web_root':
            sickbeard.WEB_ROOT,
            'log_dir':
            log_dir,
            'username':
            sickbeard.WEB_USERNAME,
            'password':
            sickbeard.WEB_PASSWORD,
            'enable_https':
            sickbeard.ENABLE_HTTPS,
            'handle_reverse_proxy':
            sickbeard.HANDLE_REVERSE_PROXY,
            'https_cert':
            sickbeard.HTTPS_CERT,
            'https_key':
            sickbeard.HTTPS_KEY,
        })
    except IOError:
        logger.log(
            u"Unable to start web server, is something else running on port %d?"
            % startPort, logger.ERROR)
Пример #9
0
    # reasons.
    if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
        webhost = sickbeard.WEB_HOST
    else:
        if sickbeard.WEB_IPV6:
            webhost = '::'
        else:
            webhost = '0.0.0.0'

    try:
        initWebServer({
            'port': startPort,
            'host': webhost,
            'data_root': os.path.join(sickbeard.PROG_DIR, 'data'),
            'web_root': sickbeard.WEB_ROOT,
            'log_dir': log_dir,
            'username': sickbeard.WEB_USERNAME,
            'password': sickbeard.WEB_PASSWORD,
            'enable_https': sickbeard.ENABLE_HTTPS,
            'https_cert': sickbeard.HTTPS_CERT,
            'https_key': sickbeard.HTTPS_KEY,
        })
    except IOError:
        logger.log(
            u"Unable to start web server, is something else running on port %d?"
            % startPort, logger.ERROR)
        if sickbeard.LAUNCH_BROWSER and not sickbeard.DAEMON:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(startPort)
        sys.exit()

    # build from the DB to start with
Пример #10
0
def main():
    """
    TV for me
    """

    # do some preliminary stuff
    sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(__file__))
    sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
    sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)
    sickbeard.DATA_DIR = sickbeard.PROG_DIR
    sickbeard.MY_ARGS = sys.argv[1:]
    sickbeard.DAEMON = False
    sickbeard.CREATEPID = False

    sickbeard.SYS_ENCODING = None

    try:
        locale.setlocale(locale.LC_ALL, "")
        sickbeard.SYS_ENCODING = locale.getpreferredencoding()
    except (locale.Error, IOError):
        pass

    # For OSes that are poorly configured I'll just randomly force UTF-8
    if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING in (
            'ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
        sickbeard.SYS_ENCODING = 'UTF-8'

    if not hasattr(sys, "setdefaultencoding"):
        reload(sys)

    try:
        # pylint: disable=E1101
        # On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
        sys.setdefaultencoding(sickbeard.SYS_ENCODING)
    except:
        sys.exit(
            "Sorry, you MUST add the Sick Beard folder to the PYTHONPATH environment variable\n"
            + "or find another way to force Python to use " +
            sickbeard.SYS_ENCODING + " for string encoding.")

    # Need console logging for SickBeard.py and SickBeard-console.exe
    consoleLogging = (not hasattr(
        sys, "frozen")) or (sickbeard.MY_NAME.lower().find('-console') > 0)

    # Rename the main thread
    threading.currentThread().name = "MAIN"

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hfqda:p::", [
            'help', 'forceupdate', 'quiet', 'nolaunch', 'daemon', 'pidfile=',
            'addr=', 'port=', 'datadir=', 'config=', 'noresize'
        ])  # @UnusedVariable
    except getopt.GetoptError:
        sys.exit(help_message())

    forceUpdate = False
    forcedHost = None
    forcedPort = None
    noLaunch = False

    for o, a in opts:

        # Prints help message
        if o in ('-h', '--help'):
            sys.exit(help_message())

        # Should we update (from tvdb) all shows in the DB right away?
        if o in ('-f', '--forceupdate'):
            forceUpdate = True

        # Disables logging to console
        if o in ('-q', '--quiet'):
            consoleLogging = False

        # Suppress launching web browser
        # Needed for OSes without default browser assigned
        # Prevent duplicate browser window when restarting in the app
        if o in ('--nolaunch', ):
            noLaunch = True

        # Run as a double forked daemon
        if o in ('-d', '--daemon'):
            sickbeard.DAEMON = True
            # When running as daemon disable consoleLogging and don't start browser
            consoleLogging = False
            noLaunch = True

            if sys.platform == 'win32':
                sickbeard.DAEMON = False

        # Write a pidfile if requested
        if o in ('--pidfile', ):
            sickbeard.CREATEPID = True
            sickbeard.PIDFILE = str(a)

            # If the pidfile already exists, sickbeard may still be running, so exit
            if os.path.exists(sickbeard.PIDFILE):
                sys.exit("PID file: " + sickbeard.PIDFILE +
                         " already exists. Exiting.")

        # Override default/configured port
        if o in ('-p', '--port'):
            try:
                forcedPort = int(a)
            except ValueError:
                sys.exit("Port: " + str(a) + " is not a number. Exiting.")

        # Override default/configured host
        if o in ('-a', '--addr'):
            try:
                forcedHost = str(a)
            except ValueError:
                sys.exit("Host: " + str(a) + " is not a string. Exiting.")

        # Specify folder to use as data dir (storing database, configfile, cache, logfiles)
        if o in ('--datadir', ):
            sickbeard.DATA_DIR = os.path.abspath(a)

        # Specify filename to load the config information from
        if o in ('--config', ):
            sickbeard.CONFIG_FILE = os.path.abspath(a)

        # Prevent resizing of the banner/posters even if PIL is installed
        if o in ('--noresize', ):
            sickbeard.NO_RESIZE = True

    # The pidfile is only useful in daemon mode, make sure we can write the file properly
    if sickbeard.CREATEPID:
        if sickbeard.DAEMON:
            pid_dir = os.path.dirname(sickbeard.PIDFILE)
            if not os.access(pid_dir, os.F_OK):
                sys.exit("PID dir: " + pid_dir + " doesn't exist. Exiting.")
            if not os.access(pid_dir, os.W_OK):
                sys.exit("PID dir: " + pid_dir +
                         " must be writable (write permissions). Exiting.")

        else:
            if consoleLogging:
                sys.stdout.write(
                    "Not running in daemon mode. PID file creation disabled.\n"
                )

            sickbeard.CREATEPID = False

    # If they don't specify a config file then put it in the data dir
    if not sickbeard.CONFIG_FILE:
        sickbeard.CONFIG_FILE = os.path.join(sickbeard.DATA_DIR, "config.ini")

    # Make sure that we can create the data dir
    if not os.access(sickbeard.DATA_DIR, os.F_OK):
        try:
            os.makedirs(sickbeard.DATA_DIR, 0744)
        except os.error:
            sys.exit("Unable to create data directory: " + sickbeard.DATA_DIR +
                     " Exiting.")

    # Make sure we can write to the data dir
    if not os.access(sickbeard.DATA_DIR, os.W_OK):
        sys.exit("Data directory: " + sickbeard.DATA_DIR +
                 " must be writable (write permissions). Exiting.")

    # Make sure we can write to the config file
    if not os.access(sickbeard.CONFIG_FILE, os.W_OK):
        if os.path.isfile(sickbeard.CONFIG_FILE):
            sys.exit("Config file: " + sickbeard.CONFIG_FILE +
                     " must be writeable (write permissions). Exiting.")
        elif not os.access(os.path.dirname(sickbeard.CONFIG_FILE), os.W_OK):
            sys.exit("Config file directory: " +
                     os.path.dirname(sickbeard.CONFIG_FILE) +
                     " must be writeable (write permissions). Exiting")

    os.chdir(sickbeard.DATA_DIR)

    if consoleLogging:
        sys.stdout.write("Starting up Sick Beard " + SICKBEARD_VERSION + "\n")
        if not os.path.isfile(sickbeard.CONFIG_FILE):
            sys.stdout.write("Unable to find '" + sickbeard.CONFIG_FILE +
                             "' , all settings will be default!" + "\n")

    # Load the config and publish it to the sickbeard package
    sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

    # Initialize the config and our threads
    sickbeard.initialize(consoleLogging=consoleLogging)

    sickbeard.showList = []

    if sickbeard.DAEMON:
        daemonize()

    # Use this PID for everything
    sickbeard.PID = os.getpid()

    if forcedPort:
        logger.log(u"Forcing web server to port " + str(forcedPort))
        startPort = forcedPort
    else:
        startPort = sickbeard.WEB_PORT

    if sickbeard.WEB_LOG:
        log_dir = sickbeard.LOG_DIR
    else:
        log_dir = None

    # sickbeard.WEB_HOST is available as a configuration value in various
    # places but is not configurable. It is supported here for historic reasons.
    if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
        webhost = sickbeard.WEB_HOST
    else:
        if sickbeard.WEB_IPV6:
            webhost = '::'
        else:
            webhost = '127.0.0.1'

    if forcedHost:
        logger.log(u"Forcing web server to address " + str(forcedHost))
        webhost = forcedHost

    try:
        initWebServer({
            'port': startPort,
            'host': webhost,
            'data_root': os.path.join(sickbeard.PROG_DIR, 'data'),
            'web_root': sickbeard.WEB_ROOT,
            'log_dir': log_dir,
            'username': sickbeard.WEB_USERNAME,
            'password': sickbeard.WEB_PASSWORD,
            'enable_https': sickbeard.ENABLE_HTTPS,
            'https_cert': sickbeard.HTTPS_CERT,
            'https_key': sickbeard.HTTPS_KEY,
        })
    except IOError:
        logger.log(
            u"Unable to start web server, is something else running on port: "
            + str(startPort), logger.ERROR)
        if sickbeard.LAUNCH_BROWSER and not sickbeard.DAEMON:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(webhost, startPort)
        sys.exit(
            "Unable to start web server, is something else running on port: " +
            str(startPort))

    # Build from the DB to start with
    logger.log(u"Loading initial show list")
    loadShowsFromDB()

    # Fire up all our threads
    sickbeard.start()

    # Launch browser if we're supposed to
    if sickbeard.LAUNCH_BROWSER and not noLaunch and not sickbeard.DAEMON:
        sickbeard.launchBrowser(webhost, startPort)

    # Start an update if we're supposed to
    if forceUpdate:
        sickbeard.showUpdateScheduler.action.run(
            force=True)  # @UndefinedVariable

    # Stay alive while my threads do the work
    while (True):

        if sickbeard.invoked_command:
            sickbeard.invoked_command()
            sickbeard.invoked_command = None

        time.sleep(1)

    return
Пример #11
0
    # reasons.
    if sickbeard.WEB_HOST and sickbeard.WEB_HOST != "0.0.0.0":
        webhost = sickbeard.WEB_HOST
    else:
        if sickbeard.WEB_IPV6:
            webhost = "::"
        else:
            webhost = "0.0.0.0"

    try:
        initWebServer(
            {
                "port": startPort,
                "host": webhost,
                "data_root": os.path.join(sickbeard.PROG_DIR, "data"),
                "web_root": sickbeard.WEB_ROOT,
                "log_dir": log_dir,
                "username": "******",
                "password": "******",
            }
        )
    except IOError:
        logger.log(u"Unable to start web server, is something else running on port %d?" % startPort, logger.ERROR)
        if sickbeard.LAUNCH_BROWSER:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(startPort)
        sys.exit()

    # build from the DB to start with
    logger.log(u"Loading initial show list")
    loadShowsFromDB()
Пример #12
0
            create_https_certificates('server.crt', 'server.key')
            sickbeard.SSL_CERT_FILE = os.path.join(os.getcwd(),'server.crt')
            sickbeard.SSL_KEY_FILE =  os.path.join(os.getcwd(),'server.key')
        if not(sickbeard.SSL_CERT_FILE != "" and os.path.exists(sickbeard.SSL_CERT_FILE)) or not (sickbeard.SSL_KEY_FILE != "" and os.path.exists(sickbeard.SSL_KEY_FILE)) :
            logger.log(u"Unable to start webserver with SSL. Configured certificate or key does not exist.")
            sickbeard.WEB_SSL = 0

    logger.log(u"Starting Sick Beard on http(s)://" + str(webhost) + ":" + str(startPort) + "/")

    try:
        initWebServer({
                'port': startPort,
                'host': webhost,
                'data_root': os.path.join(sickbeard.PROG_DIR, 'data'),
                'web_root': sickbeard.WEB_ROOT,
                'log_dir': log_dir,
                'username': sickbeard.WEB_USERNAME,
                'password': sickbeard.WEB_PASSWORD,
                'web_ssl' : sickbeard.WEB_SSL,
                'server_certificate': sickbeard.SSL_CERT_FILE,
                'server_key' :  sickbeard.SSL_KEY_FILE,
        })
    except IOError:
        logger.log(u"Unable to start web server, is something else running on port %d?" % startPort, logger.ERROR)
        if sickbeard.LAUNCH_BROWSER:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(startPort)
        sys.exit()

    # build from the DB to start with
    logger.log(u"Loading initial show list")
    loadShowsFromDB()
Пример #13
0
        webhost = sickbeard.WEB_HOST
    else:
        if sickbeard.WEB_IPV6:
            webhost = "::"
        else:
            webhost = "0.0.0.0"

    try:
        initWebServer(
            {
                "port": startPort,
                "host": webhost,
                "data_root": os.path.join(sickbeard.PROG_DIR, "gui/" + sickbeard.GUI_NAME),
                "web_root": sickbeard.WEB_ROOT,
                "log_dir": log_dir,
                "username": sickbeard.WEB_USERNAME,
                "password": sickbeard.WEB_PASSWORD,
                "enable_https": sickbeard.ENABLE_HTTPS,
                "handle_reverse_proxy": sickbeard.HANDLE_REVERSE_PROXY,
                "https_cert": sickbeard.HTTPS_CERT,
                "https_key": sickbeard.HTTPS_KEY,
            }
        )
    except IOError:
        logger.log(u"Unable to start web server, is something else running on port %d?" % startPort, logger.ERROR)
        if sickbeard.LAUNCH_BROWSER and not sickbeard.DAEMON:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(startPort)
        sys.exit()

    # Build from the DB to start with
Пример #14
0
    # places but is not configurable. It is supported here for historic
    # reasons.
    if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
        webhost = sickbeard.WEB_HOST
    else:
        if sickbeard.WEB_IPV6:
            webhost = '::'
        else:
            webhost = '0.0.0.0'

    try:
        initWebServer({
            'port': startPort,
            'host': webhost,
            'data_root': os.path.join(sickbeard.PROG_DIR, 'data'),
            'web_root': sickbeard.WEB_ROOT,
            'log_dir': log_dir,
            'username': sickbeard.WEB_USERNAME,
            'password': sickbeard.WEB_PASSWORD,
        })
    except IOError:
        logger.log(
            u"Unable to start web server, is something else running on port %d?"
            % startPort, logger.ERROR)
        if sickbeard.LAUNCH_BROWSER:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(startPort)
        sys.exit()

    # build from the DB to start with
    logger.log(u"Loading initial show list")
Пример #15
0
def main():

	# do some preliminary stuff
	sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(sys.argv[0]))
	sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
	sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)

	config_file = os.path.join(sickbeard.PROG_DIR, "config.ini")

	# need console logging for SickBeard.py and SickBeard-console.exe
	consoleLogging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find('-console') > 0)

	# rename the main thread
	threading.currentThread().name = "MAIN"

	try:
		opts, args = getopt.getopt(sys.argv[1:], "q", ['quiet'])
	except getopt.GetoptError:
		print "Available options: --quiet"
		sys.exit()
	
	for o, a in opts:
		# for now we'll just silence the logging
		if (o in ('-q', '--quiet')):
			consoleLogging = False
	
	if consoleLogging:
		print "Starting up Sick Beard "+SICKBEARD_VERSION+" from " + config_file
	
	# load the config and publish it to the sickbeard package
	if not os.path.isfile(config_file):
		logger.log("Unable to find config.ini, all settings will be default", logger.ERROR)

	sickbeard.CFG = ConfigObj(config_file)

	# initialize the config and our threads
	sickbeard.initialize(consoleLogging=consoleLogging)

	sickbeard.showList = []

	try:
		initWebServer({
		        'port':      sickbeard.WEB_PORT,
		        'data_root': os.path.join(sickbeard.PROG_DIR, 'data'),
		        'web_root':  sickbeard.WEB_ROOT,
		        'log_dir':   sickbeard.LOG_DIR if sickbeard.WEB_LOG else None,
		        'username':  sickbeard.WEB_USERNAME,
		        'password':  sickbeard.WEB_PASSWORD,
		})
	except IOError:
		logger.log("Unable to start web server, is something else running on port %d?" % sickbeard.WEB_PORT, logger.ERROR)
		if sickbeard.LAUNCH_BROWSER:
			logger.log("Launching browser and exiting", logger.ERROR)
			sickbeard.launchBrowser()
		sys.exit()

	# build from the DB to start with
	logger.log("Loading initial show list")
	loadShowsFromDB()

	# set up the lists
	sickbeard.updateAiringList()
	sickbeard.updateComingList()
	sickbeard.updateMissingList()
	
	# fire up all our threads
	sickbeard.start()

	# launch browser if we're supposed to
	if sickbeard.LAUNCH_BROWSER:
		sickbeard.launchBrowser()

	# stay alive while my threads do the work
	while (True):
		
		time.sleep(1)
	
	return
Пример #16
0
    # reasons.
    if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
        webhost = sickbeard.WEB_HOST
    else:
        if sickbeard.WEB_IPV6:
            webhost = '::'
        else:
            webhost = '0.0.0.0'

    try:
        initWebServer({
                'port': startPort,
                'host': webhost,
                'data_root': os.path.join(sickbeard.PROG_DIR, 'data'),
                'web_root': sickbeard.WEB_ROOT,
                'log_dir': log_dir,
                'username': sickbeard.WEB_USERNAME,
                'password': sickbeard.WEB_PASSWORD,
                'enable_https': sickbeard.ENABLE_HTTPS,
                'https_cert': sickbeard.HTTPS_CERT,
                'https_key': sickbeard.HTTPS_KEY,
        })
    except IOError:
        logger.log(u"Unable to start web server, is something else running on port %d?" % startPort, logger.ERROR)
        if sickbeard.LAUNCH_BROWSER and not sickbeard.DAEMON:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(startPort)
        sys.exit()

    # build from the DB to start with
    logger.log(u"Loading initial show list")
    loadShowsFromDB()
Пример #17
0
    options = {
        'port': int(startPort),
        'host': webhost,
        'data_root': os.path.join(sickbeard.PROG_DIR, 'gui', sickbeard.GUI_NAME),
        'web_root': sickbeard.WEB_ROOT,
        'log_dir': log_dir,
        'username': sickbeard.WEB_USERNAME,
        'password': sickbeard.WEB_PASSWORD,
        'enable_https': sickbeard.ENABLE_HTTPS,
        'handle_reverse_proxy': sickbeard.HANDLE_REVERSE_PROXY,
        'https_cert': sickbeard.HTTPS_CERT,
        'https_key': sickbeard.HTTPS_KEY,
    }

    # init tornado
    webserveInit.initWebServer(options)

    # Build from the DB to start with
    logger.log(u"Loading initial show list")
    loadShowsFromDB()

    def startup():
        # Fire up all our threads
        sickbeard.start()

        # Launch browser if we're supposed to
        if sickbeard.LAUNCH_BROWSER and not noLaunch and not sickbeard.DAEMON:
            sickbeard.launchBrowser(startPort)

        # Start an update if we're supposed to
        if forceUpdate or sickbeard.UPDATE_SHOWS_ON_START:
Пример #18
0
def main():
    """
    TV for me
    """

    # do some preliminary stuff
    sickbeard.MY_FULLNAME = os.path.normpath(os.path.abspath(__file__))
    sickbeard.MY_NAME = os.path.basename(sickbeard.MY_FULLNAME)
    sickbeard.PROG_DIR = os.path.dirname(sickbeard.MY_FULLNAME)
    sickbeard.DATA_DIR = sickbeard.PROG_DIR
    sickbeard.MY_ARGS = sys.argv[1:]
    sickbeard.DAEMON = False
    sickbeard.CREATEPID = False

    sickbeard.SYS_ENCODING = None

    try:
        locale.setlocale(locale.LC_ALL, "")
        sickbeard.SYS_ENCODING = locale.getpreferredencoding()
    except (locale.Error, IOError):
        pass

    # For OSes that are poorly configured I'll just randomly force UTF-8
    if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
        sickbeard.SYS_ENCODING = 'UTF-8'

    if not hasattr(sys, "setdefaultencoding"):
        reload(sys)

    try:
        # pylint: disable=E1101
        # On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
        sys.setdefaultencoding(sickbeard.SYS_ENCODING)
    except:
        sys.exit("Sorry, you MUST add the Sick Beard folder to the PYTHONPATH environment variable\n" +
            "or find another way to force Python to use " + sickbeard.SYS_ENCODING + " for string encoding.")

    # Need console logging for SickBeard.py and SickBeard-console.exe
    consoleLogging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find('-console') > 0)

    # Rename the main thread
    threading.currentThread().name = "MAIN"

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hfqdp::", ['help', 'forceupdate', 'quiet', 'nolaunch', 'daemon', 'pidfile=', 'port=', 'datadir=', 'config=', 'noresize'])  # @UnusedVariable
    except getopt.GetoptError:
        sys.exit(help_message())

    forceUpdate = False
    forcedPort = None
    noLaunch = False

    for o, a in opts:

        # Prints help message
        if o in ('-h', '--help'):
            sys.exit(help_message())

        # Should we update (from tvdb) all shows in the DB right away?
        if o in ('-f', '--forceupdate'):
            forceUpdate = True

        # Disables logging to console
        if o in ('-q', '--quiet'):
            consoleLogging = False

        # Suppress launching web browser
        # Needed for OSes without default browser assigned
        # Prevent duplicate browser window when restarting in the app
        if o in ('--nolaunch',):
            noLaunch = True

        # Run as a double forked daemon
        if o in ('-d', '--daemon'):
            sickbeard.DAEMON = True
            # When running as daemon disable consoleLogging and don't start browser
            consoleLogging = False
            noLaunch = True

            if sys.platform == 'win32':
                sickbeard.DAEMON = False

        # Write a pidfile if requested
        if o in ('--pidfile',):
            sickbeard.CREATEPID = True
            sickbeard.PIDFILE = str(a)

            # If the pidfile already exists, sickbeard may still be running, so exit
            if os.path.exists(sickbeard.PIDFILE):
                sys.exit("PID file: " + sickbeard.PIDFILE + " already exists. Exiting.")

        # Override default/configured port
        if o in ('-p', '--port'):
            try:
                forcedPort = int(a)
            except ValueError:
                sys.exit("Port: " + str(a) + " is not a number. Exiting.")

        # Specify folder to use as data dir (storing database, configfile, cache, logfiles)
        if o in ('--datadir',):
            sickbeard.DATA_DIR = os.path.abspath(a)

        # Specify filename to load the config information from
        if o in ('--config',):
            sickbeard.CONFIG_FILE = os.path.abspath(a)

        # Prevent resizing of the banner/posters even if PIL is installed
        if o in ('--noresize',):
            sickbeard.NO_RESIZE = True

    # The pidfile is only useful in daemon mode, make sure we can write the file properly
    if sickbeard.CREATEPID:
        if sickbeard.DAEMON:
            pid_dir = os.path.dirname(sickbeard.PIDFILE)
            if not os.access(pid_dir, os.F_OK):
                sys.exit("PID dir: " + pid_dir + " doesn't exist. Exiting.")
            if not os.access(pid_dir, os.W_OK):
                sys.exit("PID dir: " + pid_dir + " must be writable (write permissions). Exiting.")

        else:
            if consoleLogging:
                sys.stdout.write("Not running in daemon mode. PID file creation disabled.\n")

            sickbeard.CREATEPID = False

    # If they don't specify a config file then put it in the data dir
    if not sickbeard.CONFIG_FILE:
        sickbeard.CONFIG_FILE = os.path.join(sickbeard.DATA_DIR, "config.ini")

    # Make sure that we can create the data dir
    if not os.access(sickbeard.DATA_DIR, os.F_OK):
        try:
            os.makedirs(sickbeard.DATA_DIR, 0744)
        except os.error:
            sys.exit("Unable to create data directory: " + sickbeard.DATA_DIR + " Exiting.")

    # Make sure we can write to the data dir
    if not os.access(sickbeard.DATA_DIR, os.W_OK):
        sys.exit("Data directory: " + sickbeard.DATA_DIR + " must be writable (write permissions). Exiting.")

    # Make sure we can write to the config file
    if not os.access(sickbeard.CONFIG_FILE, os.W_OK):
        if os.path.isfile(sickbeard.CONFIG_FILE):
            sys.exit("Config file: " + sickbeard.CONFIG_FILE + " must be writeable (write permissions). Exiting.")
        elif not os.access(os.path.dirname(sickbeard.CONFIG_FILE), os.W_OK):
            sys.exit("Config file directory: " + os.path.dirname(sickbeard.CONFIG_FILE) + " must be writeable (write permissions). Exiting")

    os.chdir(sickbeard.DATA_DIR)

    if consoleLogging:
        sys.stdout.write("Starting up Sick Beard " + SICKBEARD_VERSION + "\n")
        if not os.path.isfile(sickbeard.CONFIG_FILE):
            sys.stdout.write("Unable to find '" + sickbeard.CONFIG_FILE + "' , all settings will be default!" + "\n")

    # Load the config and publish it to the sickbeard package
    sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

    # Initialize the config and our threads
    sickbeard.initialize(consoleLogging=consoleLogging)

    sickbeard.showList = []

    if sickbeard.DAEMON:
        daemonize()

    # Use this PID for everything
    sickbeard.PID = os.getpid()

    if forcedPort:
        logger.log(u"Forcing web server to port " + str(forcedPort))
        startPort = forcedPort
    else:
        startPort = sickbeard.WEB_PORT

    if sickbeard.WEB_LOG:
        log_dir = sickbeard.LOG_DIR
    else:
        log_dir = None

    # sickbeard.WEB_HOST is available as a configuration value in various
    # places but is not configurable. It is supported here for historic reasons.
    if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
        webhost = sickbeard.WEB_HOST
    else:
        if sickbeard.WEB_IPV6:
            webhost = '::'
        else:
            webhost = '0.0.0.0'

    try:
        initWebServer({
                      'port': startPort,
                      'host': webhost,
                      'data_root': os.path.join(sickbeard.PROG_DIR, 'data'),
                      'web_root': sickbeard.WEB_ROOT,
                      'log_dir': log_dir,
                      'username': sickbeard.WEB_USERNAME,
                      'password': sickbeard.WEB_PASSWORD,
                      'enable_https': sickbeard.ENABLE_HTTPS,
                      'https_cert': sickbeard.HTTPS_CERT,
                      'https_key': sickbeard.HTTPS_KEY,
                      'whitelist': sickbeard.WEB_WHITELIST,
                      })
    except IOError:
        logger.log(u"Unable to start web server, is something else running on port: " + str(startPort), logger.ERROR)
        if sickbeard.LAUNCH_BROWSER and not sickbeard.DAEMON:
            logger.log(u"Launching browser and exiting", logger.ERROR)
            sickbeard.launchBrowser(startPort)
        sys.exit("Unable to start web server, is something else running on port: " + str(startPort))

    # Build from the DB to start with
    logger.log(u"Loading initial show list")
    loadShowsFromDB()

    # Fire up all our threads
    sickbeard.start()

    # Launch browser if we're supposed to
    if sickbeard.LAUNCH_BROWSER and not noLaunch and not sickbeard.DAEMON:
        sickbeard.launchBrowser(startPort)

    # Start an update if we're supposed to
    if forceUpdate:
        sickbeard.showUpdateScheduler.action.run(force=True)  # @UndefinedVariable

    # Stay alive while my threads do the work
    while (True):

        if sickbeard.invoked_command:
            sickbeard.invoked_command()
            sickbeard.invoked_command = None

        time.sleep(1)

    return
Пример #19
0
        'port': int(startPort),
        'host': webhost,
        'data_root': os.path.join(sickbeard.PROG_DIR, 'gui',
                                  sickbeard.GUI_NAME),
        'web_root': sickbeard.WEB_ROOT,
        'log_dir': log_dir,
        'username': sickbeard.WEB_USERNAME,
        'password': sickbeard.WEB_PASSWORD,
        'enable_https': sickbeard.ENABLE_HTTPS,
        'handle_reverse_proxy': sickbeard.HANDLE_REVERSE_PROXY,
        'https_cert': sickbeard.HTTPS_CERT,
        'https_key': sickbeard.HTTPS_KEY,
    }

    # init tornado
    webserveInit.initWebServer(options)

    # Build from the DB to start with
    logger.log(u"Loading initial show list")
    loadShowsFromDB()

    def startup():
        # Fire up all our threads
        sickbeard.start()

        # Launch browser if we're supposed to
        if sickbeard.LAUNCH_BROWSER and not noLaunch and not sickbeard.DAEMON:
            sickbeard.launchBrowser(startPort)

        # Start an update if we're supposed to
        if forceUpdate or sickbeard.UPDATE_SHOWS_ON_START: