当前位置: 首页>>代码示例>>Python>>正文


Python sickbeard.initialize函数代码示例

本文整理汇总了Python中sickbeard.initialize函数的典型用法代码示例。如果您正苦于以下问题:Python initialize函数的具体用法?Python initialize怎么用?Python initialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了initialize函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main


#.........这里部分代码省略.........
    # 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({
开发者ID:pcjacobse,项目名称:Sick-Beard,代码行数:67,代码来源:SickBeard.py

示例2: start


#.........这里部分代码省略.........
        if not ek(os.access, sickbeard.DATA_DIR, os.F_OK):
            try:
                ek(os.makedirs, sickbeard.DATA_DIR, 0o744)
            except os.error:
                raise SystemExit('Unable to create data directory: {0}'.format(sickbeard.DATA_DIR))

        # Make sure we can write to the data dir
        if not ek(os.access, sickbeard.DATA_DIR, os.W_OK):
            raise SystemExit('Data directory must be writeable: {0}'.format(sickbeard.DATA_DIR))

        # Make sure we can write to the config file
        if not ek(os.access, sickbeard.CONFIG_FILE, os.W_OK):
            if ek(os.path.isfile, sickbeard.CONFIG_FILE):
                raise SystemExit('Config file must be writeable: {0}'.format(sickbeard.CONFIG_FILE))
            elif not ek(os.access, ek(os.path.dirname, sickbeard.CONFIG_FILE), os.W_OK):
                raise SystemExit('Config file root dir must be writeable: {0}'.format(ek(os.path.dirname, sickbeard.CONFIG_FILE)))

        ek(os.chdir, sickbeard.DATA_DIR)

        # Check if we need to perform a restore first
        restore_dir = ek(os.path.join, sickbeard.DATA_DIR, 'restore')
        if ek(os.path.exists, restore_dir):
            success = self.restore_db(restore_dir, sickbeard.DATA_DIR)
            if self.console_logging:
                sys.stdout.write('Restore: restoring DB and config.ini {0}!\n'.format(('FAILED', 'SUCCESSFUL')[success]))

        # Load the config and publish it to the sickbeard package
        if self.console_logging and not ek(os.path.isfile, sickbeard.CONFIG_FILE):
            sys.stdout.write('Unable to find {0}, all settings will be default!\n'.format(sickbeard.CONFIG_FILE))

        sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

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

        if self.run_as_daemon:
            self.daemonize()

        # Get PID
        sickbeard.PID = os.getpid()

        # Build from the DB to start with
        self.load_shows_from_db()

        logger.log('Starting SickRage [{branch}] using \'{config}\''.format
                   (branch=sickbeard.BRANCH, config=sickbeard.CONFIG_FILE))

        self.clear_cache()

        if self.forced_port:
            logger.log('Forcing web server to port {port}'.format(port=self.forced_port))
            self.start_port = self.forced_port
        else:
            self.start_port = sickbeard.WEB_PORT

        if sickbeard.WEB_LOG:
            self.log_dir = sickbeard.LOG_DIR
        else:
            self.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':
            self.web_host = sickbeard.WEB_HOST
        else:
            self.web_host = '' if sickbeard.WEB_IPV6 else '0.0.0.0'
开发者ID:DazzFX,项目名称:SickRage,代码行数:67,代码来源:SickBeard.py

示例3: SystemExit

        elif not os.access(os.path.dirname(sickbeard.CONFIG_FILE), os.W_OK):
            raise SystemExit("Config file root dir '" + os.path.dirname(sickbeard.CONFIG_FILE) + "' must be writeable")

    os.chdir(sickbeard.DATA_DIR)

    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 " + sickbeard.CONFIG_FILE + " , all settings will be default", logger.WARNING)

    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
开发者ID:msware,项目名称:Sick-Beard,代码行数:30,代码来源:SickBeard.py

示例4: main

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 = "::"
#.........这里部分代码省略.........
开发者ID:bergvandenp,项目名称:Sick-Beard,代码行数:101,代码来源:SickBeard.py

示例5: main

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
#.........这里部分代码省略.........
开发者ID:DaveWhite,项目名称:Sick-Beard,代码行数:101,代码来源:SickBeard.py

示例6: start


#.........这里部分代码省略.........

        # 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(u'Config file: %s must be writeable (write permissions). Exiting.' % sickbeard.CONFIG_FILE)
            elif not os.access(os.path.dirname(sickbeard.CONFIG_FILE), os.W_OK):
                sys.exit(u'Config file directory: %s must be writeable (write permissions). Exiting'
                         % os.path.dirname(sickbeard.CONFIG_FILE))
        os.chdir(sickbeard.DATA_DIR)

        if self.consoleLogging:
            print u'Starting up SickGear from %s' % sickbeard.CONFIG_FILE

        # Load the config and publish it to the sickbeard package
        if not os.path.isfile(sickbeard.CONFIG_FILE):
            print u'Unable to find "%s", all settings will be default!' % sickbeard.CONFIG_FILE

        sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

        CUR_DB_VERSION = db.DBConnection().checkDBVersion()

        if CUR_DB_VERSION > 0:
            if CUR_DB_VERSION < MIN_DB_VERSION:
                print u'Your database version (%s) is too old to migrate from with this version of SickGear' \
                      % CUR_DB_VERSION
                sys.exit(u'Upgrade using a previous version of SG first, or start with no database file to begin fresh')
            if CUR_DB_VERSION > MAX_DB_VERSION:
                print u'Your database version (%s) has been incremented past what this version of SickGear supports' \
                      % CUR_DB_VERSION
                sys.exit(
                    u'If you have used other forks of SG, your database may be unusable due to their modifications')

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

        if self.runAsDaemon:
            self.daemonize()

        # Get PID
        sickbeard.PID = os.getpid()

        if self.forcedPort:
            logger.log(u'Forcing web server to port %s' % self.forcedPort)
            self.startPort = self.forcedPort
        else:
            self.startPort = sickbeard.WEB_PORT

        if sickbeard.WEB_LOG:
            self.log_dir = sickbeard.LOG_DIR
        else:
            self.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':
            self.webhost = sickbeard.WEB_HOST
        else:
            if sickbeard.WEB_IPV6:
                self.webhost = '::'
            else:
                self.webhost = '0.0.0.0'

        # web server options
        self.web_options = {
            'port': int(self.startPort),
            'host': self.webhost,
开发者ID:Koernia,项目名称:SickGear,代码行数:67,代码来源:SickBeard.py

示例7: start


#.........这里部分代码省略.........
            try:
                ek(os.makedirs, sickbeard.DATA_DIR, 0744)
            except os.error:
                raise SystemExit("Unable to create datadir '" + sickbeard.DATA_DIR + "'")

        # Make sure we can write to the data dir
        if not ek(os.access, sickbeard.DATA_DIR, os.W_OK):
            raise SystemExit("Datadir must be writeable '" + sickbeard.DATA_DIR + "'")

        # Make sure we can write to the config file
        if not ek(os.access, sickbeard.CONFIG_FILE, os.W_OK):
            if ek(os.path.isfile, sickbeard.CONFIG_FILE):
                raise SystemExit("Config file '" + sickbeard.CONFIG_FILE + "' must be writeable.")
            elif not ek(os.access, ek(os.path.dirname, sickbeard.CONFIG_FILE), os.W_OK):
                raise SystemExit(
                    "Config file root dir '" + ek(os.path.dirname, sickbeard.CONFIG_FILE) + "' must be writeable.")

        ek(os.chdir, sickbeard.DATA_DIR)

        # Check if we need to perform a restore first
        restoreDir = ek(os.path.join, sickbeard.DATA_DIR, 'restore')
        if ek(os.path.exists, restoreDir):
            success = self.restoreDB(restoreDir, sickbeard.DATA_DIR)
            if self.consoleLogging:
                sys.stdout.write(u"Restore: restoring DB and config.ini %s!\n" % ("FAILED", "SUCCESSFUL")[success])

        # Load the config and publish it to the sickbeard package
        if self.consoleLogging and not ek(os.path.isfile, sickbeard.CONFIG_FILE):
            sys.stdout.write(u"Unable to find '" + sickbeard.CONFIG_FILE + "' , all settings will be default!" + "\n")

        sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

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

        if self.runAsDaemon:
            self.daemonize()

        # Get PID
        sickbeard.PID = os.getpid()

        # Build from the DB to start with
        self.loadShowsFromDB()

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

        if sickbeard.WEB_LOG:
            self.log_dir = sickbeard.LOG_DIR
        else:
            self.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':
            self.webhost = sickbeard.WEB_HOST
        else:
            if sickbeard.WEB_IPV6:
                self.webhost = ''
            else:
                self.webhost = '0.0.0.0'

        # web server options
开发者ID:jzoch2,项目名称:SickRage,代码行数:67,代码来源:SickBeard.py

示例8: main

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
开发者ID:basti1,项目名称:Sick-Beard,代码行数:78,代码来源:SickBeard.py

示例9: start


#.........这里部分代码省略.........
            try:
                ek(os.makedirs, sickbeard.DATA_DIR, 0o744)
            except os.error as e:
                raise SystemExit("Unable to create datadir '" + sickbeard.DATA_DIR + "'")

        # Make sure we can write to the data dir
        if not ek(os.access, sickbeard.DATA_DIR, os.W_OK):
            raise SystemExit("Datadir must be writeable '" + sickbeard.DATA_DIR + "'")

        # Make sure we can write to the config file
        if not ek(os.access, sickbeard.CONFIG_FILE, os.W_OK):
            if ek(os.path.isfile, sickbeard.CONFIG_FILE):
                raise SystemExit("Config file '" + sickbeard.CONFIG_FILE + "' must be writeable.")
            elif not ek(os.access, ek(os.path.dirname, sickbeard.CONFIG_FILE), os.W_OK):
                raise SystemExit(
                        "Config file root dir '" + ek(os.path.dirname, sickbeard.CONFIG_FILE) + "' must be writeable.")

        ek(os.chdir, sickbeard.DATA_DIR)

        # Check if we need to perform a restore first
        restoreDir = ek(os.path.join, sickbeard.DATA_DIR, 'restore')
        if ek(os.path.exists, restoreDir):
            success = self.restoreDB(restoreDir, sickbeard.DATA_DIR)
            if self.consoleLogging:
                sys.stdout.write("Restore: restoring DB and config.ini %s!\n" % ("FAILED", "SUCCESSFUL")[success])

        # Load the config and publish it to the sickbeard package
        if self.consoleLogging and not ek(os.path.isfile, sickbeard.CONFIG_FILE):
            sys.stdout.write("Unable to find '" + sickbeard.CONFIG_FILE + "' , all settings will be default!" + "\n")

        sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

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

        if self.runAsDaemon:
            sickbeard.DAEMONIZE = True
            self.daemonize()

        # Get PID
        sickbeard.PID = os.getpid()

        # Build from the DB to start with
        self.loadShowsFromDB()

        if self.forcedPort:
            logging.info("Forcing web server to port " + str(self.forcedPort))
            self.startPort = self.forcedPort
        else:
            self.startPort = sickbeard.WEB_PORT

        if sickbeard.WEB_LOG:
            self.log_dir = sickbeard.LOG_DIR
        else:
            self.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':
            self.webhost = sickbeard.WEB_HOST
        else:
            if sickbeard.WEB_IPV6:
                self.webhost = '::'
            else:
                self.webhost = '0.0.0.0'
开发者ID:coderbone,项目名称:SickRage,代码行数:66,代码来源:SickBeard.py

示例10: start


#.........这里部分代码省略.........
                ek(os.makedirs, sickbeard.DATA_DIR, 0o744)
            except os.error:
                raise SystemExit("Unable to create data directory: %s" % sickbeard.DATA_DIR)

        # Make sure we can write to the data dir
        if not ek(os.access, sickbeard.DATA_DIR, os.W_OK):
            raise SystemExit("Data directory must be writeable: %s" % sickbeard.DATA_DIR)

        # Make sure we can write to the config file
        if not ek(os.access, sickbeard.CONFIG_FILE, os.W_OK):
            if ek(os.path.isfile, sickbeard.CONFIG_FILE):
                raise SystemExit("Config file must be writeable: %s" % sickbeard.CONFIG_FILE)
            elif not ek(os.access, ek(os.path.dirname, sickbeard.CONFIG_FILE), os.W_OK):
                raise SystemExit(
                    "Config file root dir must be writeable: %s" % ek(os.path.dirname, sickbeard.CONFIG_FILE)
                )

        ek(os.chdir, sickbeard.DATA_DIR)

        # Check if we need to perform a restore first
        restore_dir = ek(os.path.join, sickbeard.DATA_DIR, "restore")
        if ek(os.path.exists, restore_dir):
            success = self.restore_db(restore_dir, sickbeard.DATA_DIR)
            if self.console_logging:
                sys.stdout.write("Restore: restoring DB and config.ini %s!\n" % ("FAILED", "SUCCESSFUL")[success])

        # Load the config and publish it to the sickbeard package
        if self.console_logging and not ek(os.path.isfile, sickbeard.CONFIG_FILE):
            sys.stdout.write("Unable to find %s, all settings will be default!\n" % sickbeard.CONFIG_FILE)

        sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)

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

        if self.run_as_daemon:
            self.daemonize()

        # Get PID
        sickbeard.PID = os.getpid()

        # Build from the DB to start with
        self.load_shows_from_db()

        logger.log("Starting SickRage [%s] from '%s'" % (sickbeard.BRANCH, sickbeard.CONFIG_FILE))

        self.clear_cache()

        if self.forced_port:
            logger.log("Forcing web server to port %s" % self.forced_port)
            self.start_port = self.forced_port
        else:
            self.start_port = sickbeard.WEB_PORT

        if sickbeard.WEB_LOG:
            self.log_dir = sickbeard.LOG_DIR
        else:
            self.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":
            self.web_host = sickbeard.WEB_HOST
        else:
            self.web_host = "" if sickbeard.WEB_IPV6 else "0.0.0.0"
开发者ID:adaur,项目名称:SickRage,代码行数:66,代码来源:SickBeard.py

示例11: start


#.........这里部分代码省略.........
                print('Your [%s] database version (%s) is a test db version and doesn\'t match SickGear required '
                      'version (%s), downgrading to production db' % (d, cur_db_version, max_v))
                self.execute_rollback(mo, max_v)
                cur_db_version = db.DBConnection(d).checkDBVersion()
                if cur_db_version >= 100000:
                    print(u'Rollback to production failed.')
                    sys.exit(u'If you have used other forks, your database may be unusable due to their changes')
                if 100000 <= max_v and None is not base_v:
                    max_v = base_v  # set max_v to the needed base production db for test_db
                print(u'Rollback to production of [%s] successful.' % d)

            # handling of production db versions
            if 0 < cur_db_version < 100000:
                if cur_db_version < min_v:
                    print(u'Your [%s] database version (%s) is too old to migrate from with this version of SickGear'
                          % (d, cur_db_version))
                    sys.exit(u'Upgrade using a previous version of SG first,'
                             + u' or start with no database file to begin fresh')
                if cur_db_version > max_v:
                    print(u'Your [%s] database version (%s) has been incremented past'
                          u' what this version of SickGear supports. Trying to rollback now. Please wait...' %
                          (d, cur_db_version))
                    self.execute_rollback(mo, max_v)
                    if db.DBConnection(d).checkDBVersion() > max_v:
                        print(u'Rollback failed.')
                        sys.exit(u'If you have used other forks, your database may be unusable due to their changes')
                    print(u'Rollback of [%s] successful.' % d)

        # free memory
        global rollback_loaded
        rollback_loaded = None

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

        if self.run_as_daemon:
            self.daemonize()

        # Get PID
        sickbeard.PID = os.getpid()

        if self.forced_port:
            logger.log(u'Forcing web server to port %s' % self.forced_port)
            self.start_port = self.forced_port
        else:
            self.start_port = sickbeard.WEB_PORT

        if sickbeard.WEB_LOG:
            self.log_dir = sickbeard.LOG_DIR
        else:
            self.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':
            self.webhost = sickbeard.WEB_HOST
        else:
            self.webhost = (('0.0.0.0', '::')[sickbeard.WEB_IPV6], '')[sickbeard.WEB_IPV64]

        # web server options
        self.web_options = dict(
            host=self.webhost,
            port=int(self.start_port),
            web_root=sickbeard.WEB_ROOT,
            data_root=os.path.join(sickbeard.PROG_DIR, 'gui', sickbeard.GUI_NAME),
            log_dir=self.log_dir,
开发者ID:JackDandy,项目名称:SickGear,代码行数:67,代码来源:sickgear.py

示例12: setUp

 def setUp(self):
     sickbeard.CONFIG_FILE = "../config.ini"
     sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)
     sickbeard.initialize(consoleLogging=False)
开发者ID:Pakoach,项目名称:Sick-Beard-Animes,代码行数:4,代码来源:test_lib.py

示例13: main

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:
#.........这里部分代码省略.........
开发者ID:pairofdimes,项目名称:Sick-Beard,代码行数:101,代码来源:SickBeard.py

示例14: main

def main():

	# do some preliminary stuff
	sickbeard.PROG_DIR = os.path.dirname(os.path.normpath(os.path.abspath(sys.argv[0])))
	sickbeard.CONFIG_FILE = "config.ini"

	# rename the main thread
	threading.currentThread().name = "MAIN"
	
	print "Starting up Sick Beard "+SICKBEARD_VERSION+" from " + os.path.join(sickbeard.PROG_DIR, sickbeard.CONFIG_FILE)
	
	# load the config and publish it to the sickbeard package
	if not os.path.isfile(os.path.join(sickbeard.PROG_DIR, sickbeard.CONFIG_FILE)):
		logger.log("Unable to find config.ini, all settings will be default", logger.ERROR)

	sickbeard.CFG = ConfigObj(os.path.join(sickbeard.PROG_DIR, sickbeard.CONFIG_FILE))

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

	sickbeard.showList = []

	# setup cherrypy logging
	if os.path.isdir(sickbeard.LOG_DIR) and sickbeard.WEB_LOG:
		cherry_log = os.path.join(sickbeard.LOG_DIR, "cherrypy.log")
		logger.log("Using " + cherry_log + " for cherrypy log")
	else:
		cherry_log = None

	# cherrypy setup
	cherrypy.config.update({
						    'server.socket_port': sickbeard.WEB_PORT,
						    'server.socket_host': '0.0.0.0',
						    'log.screen': False,
						    'log.access_file': cherry_log
	})
	
	userpassdict = {sickbeard.WEB_USERNAME: sickbeard.WEB_PASSWORD}
	checkpassword = cherrypy.lib.auth_basic.checkpassword_dict(userpassdict)
	
	if sickbeard.WEB_USERNAME == "" or sickbeard.WEB_PASSWORD == "":
		useAuth = False
	else:
		useAuth = True 
	
	conf = {
			'/': {
				'tools.staticdir.root': os.path.join(sickbeard.PROG_DIR, 'data'),
				'tools.auth_basic.on': useAuth,
				'tools.auth_basic.realm': 'SickBeard',
				'tools.auth_basic.checkpassword': checkpassword
			},
			'/images': {
				'tools.staticdir.on': True,
				'tools.staticdir.dir': 'images'
			},
			'/js':	   {
				'tools.staticdir.on': True,
				'tools.staticdir.dir': 'js'
			},
			'/css':	   {
				'tools.staticdir.on': True,
				'tools.staticdir.dir': 'css'
			},
	}

	cherrypy.tree.mount(WebInterface(), sickbeard.WEB_ROOT, conf)

	try:
		cherrypy.server.start()
		cherrypy.server.wait()
	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
开发者ID:mattsch,项目名称:Sickbeard,代码行数:100,代码来源:SickBeard.py


注:本文中的sickbeard.initialize函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。