Logo Search packages:      
Sourcecode: hellanzb version File versions  Download package

def Hellanzb::Core::init (   options = {}  ) 

initialize the app 

Definition at line 199 of file Core.py.

00199                    {}):
    """ initialize the app """
    # Whether or not the app is in the process of shutting down
    Hellanzb.SHUTDOWN = False

    # Get logging going ASAP

    # CTRL-C shutdown return code
    Hellanzb.SHUTDOWN_CODE = 20

    # defineServer's from the config file
    Hellanzb.SERVERS = {}

    # we can compare the current thread's ident to our MAIN_THREAD's to determine whether
    # or not we may need to route things through twisted's callFromThread
    Hellanzb.MAIN_THREAD_IDENT = thread.get_ident()

    Hellanzb.BEGIN_TIME = time.time()

    # Whether or not the downloader has been paused
    Hellanzb.downloadPaused = False

    # Troll threads
    Hellanzb.postProcessors = []
    Hellanzb.postProcessorLock = Lock()

    # How many total NZB archives have been post processed
    Hellanzb.totalPostProcessed = 0

    # Whether or not we're a downloader process
    Hellanzb.IS_DOWNLOADER = False

    # Whether or not the queue daemon is running as a daemon process (forked)
    Hellanzb.DAEMONIZE = False

    # Whether or not debug logging is enabled
    Hellanzb.DEBUG_MODE_ENABLED = False
    # How many times CTRL-C has been pressed
    Hellanzb.stopSignalCount = 0
    # When the first CTRL-C was pressed
    Hellanzb.firstSignal = None
    # Message printed before exiting
    Hellanzb.shutdownMessage = None

    # Whether or not this is a hellanzb download daemon process
    Hellanzb.isDaemon = False

    # The name of the loaded config file
    Hellanzb.CONFIG_FILENAME = None

    # hostname we're running on
    Hellanzb.HOSTNAME = gethostname()

    (sysname, nodename, release, version, machine) = os.uname()
    # The OS in use
    Hellanzb.SYSNAME = sysname

    # Only add anonymous NZB files placed in the QUEUE_DIR to the NZBQueue after this
    # number have seconds have passed since the files modification time
    Hellanzb.NZBQUEUE_MDELAY = 10
    # Whether or not the C yenc module is installed
        import _yenc
        Hellanzb.HAVE_C_YENC = True
    except ImportError:
        Hellanzb.HAVE_C_YENC = False

    Hellanzb.PACKAGER = find_packager()
    if isPy2App():
        # Append the py2app Contents/Resources dir to the PATH
        import __main__
        os.environ['PATH'] = os.environ['PATH'] + ':' + \

    # Twisted will replace this with its own signal handler when initialized
    signal.signal(signal.SIGINT, signalHandler)

    outlineRequiredDirs() # before the config file is loaded
    if hasattr(options, 'configFile') and options.configFile is not None:

    # FIXME: these blocks below, and some code in loadConfig should all be pulled out into
    # a post-loadConfig normalizeConfig function. Could we skip any of this init stuff
    # when just making an RPC call (to reduce startup time)?
    for attr in ('logFile', 'debugLogFile'):
        # this is really: logFile = None
        setattr(sys.modules[__name__], attr, None)
        if hasattr(options, attr) and getattr(options, attr) is not None:
            setattr(sys.modules[__name__], attr, getattr(options, attr))
    Hellanzb.Logging.initLogFile(logFile = logFile, debugLogFile = debugLogFile)

    # overwrite xml rpc vars from the command line options if they were set
    for option, attr in { 'rpcServer': 'XMLRPC_SERVER',
                          'rpcPassword': 'XMLRPC_PASSWORD',
                          'rpcPort': 'XMLRPC_PORT' }.iteritems():
        if hasattr(options, option) and getattr(options, option) is not None:
            setattr(Hellanzb, attr, getattr(options, option))

    if not hasattr(Hellanzb, 'DELETE_PROCESSED'):
        Hellanzb.DELETE_PROCESSED = True

    if hasattr(Hellanzb, 'UMASK'):
            Hellanzb.UMASK = int(Hellanzb.UMASK)
        except ValueError:
            error('Config file option: Hellanzb.UMASK is not a valid integer')

    if not hasattr(Hellanzb, 'GROWL_NOTIFY'):
        error('Required option not defined in config file: Hellanzb.GROWL_NOTIFY')
    elif Hellanzb.GROWL_NOTIFY:
        errors = []
        for attr in ('GROWL_SERVER', 'GROWL_PASSWORD'):
            if not hasattr(Hellanzb, attr):
                err = 'Hellanzb.GROWL_NOTIFY enabled. Required option not defined in config file: Hellanzb.'
                errors.append(err + attr)
        if len(errors):
            [error(err) for err in errors]

Generated by  Doxygen 1.6.0   Back to index