Example #1
0
def initialize(name):
	"""
	Initializes a logging producer registered under the specified name.
	
	Overrides the built-in logging.getLogger(name) to check that name is
	a valid source name. Attempts to connect this producer to the server
	and raises an exception if this fails. Sets the default logging
	level to DEBUG so that the server has a chance to see all messages.
	"""
	_getLogger = getLogger

	def clientGetLogger(name=None):
		"""
		Overrides the built-in implementation to check for a valid source name.
		"""
		if name:
			source = ResourceName(name)
		return _getLogger(name)
	
	globals()["getLogger"] = clientGetLogger

	source = ResourceName(name)	
	clientHandler = ClientHandler(source,
		config.get('logger','unix_addr'),
		config.get('logger','tcp_host'),
		config.get('logger','tcp_port')
	)
	root.handlers.append(clientHandler)
	root.setLevel(DEBUG)
Example #2
0
def initialize(name):
	"""
	Initializes the producer side of distributed archiving.
	
	Should usually be called right after importing this module. Must be
	called before archiving is started or any records are defined. This
	function attempts to connect to the archiving server and will raise
	an exception if this fails.
	
	The name provided must be a valid and unique network service name.
	See tops.core.network.naming for details.
	"""
	global theArchive
	assert(theArchive is None)
	theArchive = ArchiveClient(name,
		config.get('archiver','unix_addr'),
		config.get('archiver','tcp_host'),
		config.get('archiver','tcp_port')
	)
Example #3
0
            # load our run-time configuration
    verbose = config.initialize("start")

    # prompt for the decryption passphrase used for private data if requested
    private_key = None
    if config.getboolean("start", "get_passphrase"):
        passphrase = getpass.getpass("Enter the pass phrase: ")
        engine = secret.SecretEngine(passphrase=passphrase)
        private_key = engine.key
        del engine

        # collect a list of services to start and perform some checks
    services = {}
    for section in config.theParser.sections():
        service_name = config.get(section, "service")
        launch_order = config.getint(section, "launch_order")
        if service_name and launch_order and config.getboolean(section, "enable"):
            # convert this service name to a filesystem path
            try:
                __import__(service_name, globals(), locals(), ["__file__"], -1)
            except ImportError:
                print "start: Unable to import service %s" % service_name
                sys.exit(-1)
            path = sys.modules[service_name].__file__
            # check that a readable file exists at this path
            if not os.path.isfile(path):
                print "start: Mo such file %s" % path
                sys.exit(-2)
            if verbose:
                print "start: Located %s at %s" % (service_name, path)