• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sickbeard.start函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: startup

    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:
            sickbeard.showUpdateScheduler.action.run(force=True)  # @UndefinedVariable
开发者ID:dnssyste,项目名称:SickRage,代码行数:11,代码来源:SickBeard.py


示例2: run

    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()
开发者ID:BeegorMif,项目名称:HTPC-Manager,代码行数:39,代码来源:SickBeard.py


示例3: main


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

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


示例4: loadShowsFromDB

                '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()

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


示例5: start

    def start(self):  # pylint: disable=too-many-branches,too-many-statements
        """
        Start SickRage
        """
        # do some preliminary stuff
        sickbeard.MY_FULLNAME = ek(os.path.normpath, ek(os.path.abspath, __file__))
        sickbeard.MY_NAME = ek(os.path.basename, sickbeard.MY_FULLNAME)
        sickbeard.PROG_DIR = ek(os.path.dirname, sickbeard.MY_FULLNAME)
        sickbeard.DATA_DIR = sickbeard.PROG_DIR
        sickbeard.MY_ARGS = sys.argv[1:]

        try:
            locale.setlocale(locale.LC_ALL, '')
            sickbeard.SYS_ENCODING = locale.getpreferredencoding()
        except (locale.Error, IOError):
            sickbeard.SYS_ENCODING = 'UTF-8'

        # pylint: disable=no-member
        if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING.lower() in ('ansi_x3.4-1968', 'us-ascii', 'ascii', 'charmap') or \
                (sys.platform.startswith('win') and sys.getwindowsversion()[0] >= 6 and str(getattr(sys.stdout, 'device', sys.stdout).encoding).lower() in ('cp65001', 'charmap')):
            sickbeard.SYS_ENCODING = 'UTF-8'

        # TODO: Continue working on making this unnecessary, this hack creates all sorts of hellish problems
        if not hasattr(sys, 'setdefaultencoding'):
            reload(sys)

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

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

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

        try:
            opts, _ = getopt.getopt(
                sys.argv[1:], 'hqdp::',
                ['help', 'quiet', 'nolaunch', 'daemon', 'pidfile=', 'port=', 'datadir=', 'config=', 'noresize']
            )
        except getopt.GetoptError:
            sys.exit(self.help_message())

        for option, value in opts:
            # Prints help message
            if option in ('-h', '--help'):
                sys.exit(self.help_message())

            # For now we'll just silence the logging
            if option in ('-q', '--quiet'):
                self.console_logging = False

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

            # Override default/configured port
            if option in ('-p', '--port'):
                try:
                    self.forced_port = int(value)
                except ValueError:
                    sys.exit('Port: {0} is not a number. Exiting.'.format(value))

            # Run as a double forked daemon
            if option in ('-d', '--daemon'):
                self.run_as_daemon = True
                # When running as daemon disable console_logging and don't start browser
                self.console_logging = False
                self.no_launch = True

                if sys.platform == 'win32' or sys.platform == 'darwin':
                    self.run_as_daemon = False

            # Write a pid file if requested
            if option in ('--pidfile',):
                self.create_pid = True
                self.pid_file = str(value)

                # If the pid file already exists, SickRage may still be running, so exit
                if ek(os.path.exists, self.pid_file):
                    sys.exit('PID file: {0} already exists. Exiting.'.format(self.pid_file))

            # Specify folder to load the config file from
            if option in ('--config',):
                sickbeard.CONFIG_FILE = ek(os.path.abspath, value)

            # Specify folder to use as the data directory
            if option in ('--datadir',):
                sickbeard.DATA_DIR = ek(os.path.abspath, value)

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

#.........这里部分代码省略.........
开发者ID:DazzFX,项目名称:SickRage,代码行数:101,代码来源:SickBeard.py


示例6: 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


示例7: 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


示例8: start

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

        try:
            locale.setlocale(locale.LC_ALL, "")
            sickbeard.SYS_ENCODING = locale.getpreferredencoding()
        except (locale.Error, IOError):
            sickbeard.SYS_ENCODING = 'UTF-8'

        # pylint: disable=no-member
        if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING.lower() in ('ansi_x3.4-1968', 'us-ascii', 'ascii', 'charmap') or \
            (sys.platform.startswith('win') and sys.getwindowsversion()[0] >= 6 and str(getattr(sys.stdout, 'device', sys.stdout).encoding).lower() in ('cp65001', 'charmap')):
            sickbeard.SYS_ENCODING = 'UTF-8'

        # TODO: Continue working on making this unnecessary, this hack creates all sorts of hellish problems
        if not hasattr(sys, "setdefaultencoding"):
            reload(sys)

        try:
            # pylint: disable=no-member
            # 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 Exception:
            sys.exit("Sorry, you MUST add the SickRage 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
        self.consoleLogging = (not hasattr(sys, "frozen")) or (sickbeard.MY_NAME.lower().find('-console') > 0)

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

        try:
            opts, _ = getopt.getopt(
                sys.argv[1:], "hqdp::",
                ['help', 'quiet', 'nolaunch', 'daemon', 'pidfile=', 'port=', 'datadir=', 'config=', 'noresize']
            )
        except getopt.GetoptError:
            sys.exit(self.help_message())

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

            # For now we'll just silence the logging
            if o in ('-q', '--quiet'):
                self.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',):
                self.noLaunch = True

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

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

                if sys.platform == 'win32' or sys.platform == 'darwin':
                    self.runAsDaemon = False

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

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

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

            # Specify folder to use as the data dir
            if o in ('--datadir',):
                sickbeard.DATA_DIR = ek(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 self.CREATEPID:
#.........这里部分代码省略.........
开发者ID:jzoch2,项目名称:SickRage,代码行数:101,代码来源:SickBeard.py


示例9: start

    def start(self):
        # 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.SYS_ENCODING = None

        try:
            locale.setlocale(locale.LC_ALL, '')
        except (locale.Error, IOError):
            pass
        try:
            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:
            print 'Sorry, you MUST add the SickGear folder to the PYTHONPATH environment variable'
            print 'or find another way to force Python to use %s for string encoding.' % sickbeard.SYS_ENCODING
            sys.exit(1)

        # Need console logging for SickBeard.py and SickBeard-console.exe
        self.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(self.help_message())

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

            # For now we'll just silence the logging
            if o in ('-q', '--quiet'):
                self.consoleLogging = False

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

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

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

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

                if sys.platform == 'win32':
                    self.runAsDaemon = False

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

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

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

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

#.........这里部分代码省略.........
开发者ID:Koernia,项目名称:SickGear,代码行数:101,代码来源:SickBeard.py


示例10: start

    def start(self):
        # Rename the main thread
        threading.currentThread().name = "MAIN"

        # initalize encoding defaults
        encodingInit()

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

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

        # Do this before importing sickbeard, to prevent locked files and incorrect import
        oldtornado = ek(os.path.abspath, ek(os.path.join, ek(os.path.dirname, __file__), 'tornado'))
        if ek(os.path.isdir, oldtornado):
            ek(shutil.move, oldtornado, oldtornado + '_kill')
            ek(removetree, oldtornado + '_kill')

        try:
            opts, _ = getopt.getopt(
                    sys.argv[1:], "hqdp::",
                    ['help', 'quiet', 'nolaunch', 'daemon', 'pidfile=', 'port=', 'datadir=', 'config=', 'noresize']
            )
        except getopt.GetoptError:
            sys.exit(self.help_message())

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

            # For now we'll just silence the logging
            if o in ('-q', '--quiet'):
                self.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',):
                self.noLaunch = True

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

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

                if sys.platform == 'win32' or sys.platform == 'darwin':
                    self.runAsDaemon = False

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

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

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

            # Specify folder to use as the data dir
            if o in ('--datadir',):
                sickbeard.DATA_DIR = ek(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 self.CREATEPID:
            if self.runAsDaemon:
                pid_dir = ek(os.path.dirname, self.PIDFILE)
                if not ek(os.access, pid_dir, os.F_OK):
                    sys.exit("PID dir: " + pid_dir + " doesn't exist. Exiting.")
                if not ek(os.access, pid_dir, os.W_OK):
                    sys.exit("PID dir: " + pid_dir + " must be writable (write permissions). Exiting.")

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

                self.CREATEPID = False

        # If they don't specify a config file then put it in the data dir
#.........这里部分代码省略.........
开发者ID:coderbone,项目名称:SickRage,代码行数:101,代码来源:SickBeard.py


示例11: 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


示例12: start

    def start(self):  # pylint: disable=too-many-branches,too-many-statements
        """
        Start SickRage
        """
        # do some preliminary stuff
        sickbeard.MY_FULLNAME = ek(os.path.normpath, ek(os.path.abspath, __file__))
        sickbeard.MY_NAME = ek(os.path.basename, sickbeard.MY_FULLNAME)
        sickbeard.PROG_DIR = ek(os.path.dirname, sickbeard.MY_FULLNAME)
        sickbeard.DATA_DIR = sickbeard.PROG_DIR
        sickbeard.MY_ARGS = sys.argv[1:]

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

        # pylint: disable=no-member
        if (
            not sickbeard.SYS_ENCODING
            or sickbeard.SYS_ENCODING.lower() in ("ansi_x3.4-1968", "us-ascii", "ascii", "charmap")
            or (
                sys.platform.startswith("win")
                and sys.getwindowsversion()[0] >= 6
                and str(getattr(sys.stdout, "device", sys.stdout).encoding).lower() in ("cp65001", "charmap")
            )
        ):
            sickbeard.SYS_ENCODING = "UTF-8"

        # TODO: Continue working on making this unnecessary, this hack creates all sorts of hellish problems
        if not hasattr(sys, "setdefaultencoding"):
            reload(sys)

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

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

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

        try:
            opts, _ = getopt.getopt(
                sys.argv[1:],
                "hqdp::",
                ["help", "quiet", "nolaunch", "daemon", "pidfile=", "port=", "datadir=", "config=", "noresize"],
            )
        except getopt.GetoptError:
            sys.exit(self.help_message())

        for option, value in opts:
            # Prints help message
            if option in ("-h", "--help"):
                sys.exit(self.help_message())

            # For now we'll just silence the logging
            if option in ("-q", "--quiet"):
                self.console_logging = False

            # Suppress launching web browser
            # Needed for OSes without default browser assigned
            # Prevent duplicate browser window when restarting in the app
            if option in ("--nolaunch",):
                self.no_launch = True

            # Override default/configured port
            if option in ("-p", "--port"):
                try:
                    self.forced_port = int(value)
                except ValueError:
                    sys.exit("Port: %s is not a number. Exiting." % value)

            # Run as a double forked daemon
            if option in ("-d", "--daemon"):
                self.run_as_daemon = True
                # When running as daemon disable console_logging and don't start browser
                self.console_logging = False
                self.no_launch = True

                if sys.platform == "win32" or sys.platform == "darwin":
                    self.run_as_daemon = False

            # Write a pid file if requested
            if option in ("--pidfile",):
                self.create_pid = True
                self.pid_file = str(value)

                # If the pid file already exists, SickRage may still be running, so exit
                if ek(os.path.exists, self.pid_file):
                    sys.exit("PID file: %s already exists. Exiting." % self.pid_file)

            # Specify folder to load the config file from
            if option in ("--config",):
#.........这里部分代码省略.........
开发者ID:adaur,项目名称:SickRage,代码行数:101,代码来源:SickBeard.py


示例13: start

    def start(self):
        # 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.SYS_ENCODING = None

        try:
            locale.setlocale(locale.LC_ALL, '')
        except (locale.Error, IOError):
            pass
        try:
            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'):
            moves.reload_module(sys)

        try:
            # pylint: disable=E1101
            # On non-unicode builds this raises an AttributeError, if encoding type is not valid it throws a LookupError
            sys.setdefaultencoding(sickbeard.SYS_ENCODING)
        except (StandardError, Exception):
            print('Sorry, you MUST add the SickGear folder to the PYTHONPATH environment variable')
            print('or find another way to force Python to use %s for string encoding.' % sickbeard.SYS_ENCODING)
            sys.exit(1)

        # Need console logging for SickBeard.py and SickBeard-console.exe
        self.console_logging = (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:], 'hfqdsp::',
                                       ['help', 'forceupdate', 'quiet', 'nolaunch', 'daemon', 'systemd', 'pidfile=',
                                        'port=', 'datadir=', 'config=', 'noresize'])  # @UnusedVariable
        except getopt.GetoptError:
            sys.exit(self.help_message())

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

            # For now we'll just silence the logging
            if o in ('-q', '--quiet'):
                self.console_logging = False

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

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

            # Override default/configured port
            if o in ('-p', '--port'):
                try:
                    self.forced_port = int(a)
                except ValueError:
                    sys.exit('Port: %s is not a number. Exiting.' % a)

            # Run as a double forked daemon
            if o in ('-d', '--daemon'):
                self.run_as_daemon = True
                # When running as daemon disable console_logging and don't start browser
                self.console_logging = False
                self.no_launch = True

                if 'win32' == sys.platform:
                    self.run_as_daemon = False

            # Run as a systemd service
            if o in ('-s', '--systemd') and 'win32' != sys.platform:
                self.run_as_systemd = True
                self.run_as_daemon = False
                self.console_logging = False
                self.no_launch = True

            # Write a pidfile if requested
            if o in ('--pidfile',):
                self.create_pid = True
                self.pid_file = str(a)

                # If the pidfile already exists, sickbeard may still be running, so exit
                if os.path.exists(self.pid_file):
                    sys.exit('PID file: %s already exists. Exiting.' % self.pid_file)

            # Specify folder to load the config file from
#.........这里部分代码省略.........
开发者ID:JackDandy,项目名称:SickGear,代码行数:101,代码来源:sickgear.py


示例14: 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:
        s 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python clients.getClientIstance函数代码示例发布时间:2022-05-27
下一篇:
Python sickbeard.save_config函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap