Example #1
0
def _setupLogging():
    global results_log
    if results_log is not None:
        return

    # Make sure that the root logger isn't configured already. If it does,
    # this basicConfig will be a noop and not setup the expected file handler
    # on the logger.
    root_logger = logging.getLogger()
    for handler in root_logger.handlers[:]:
        root_logger.removeHandler(handler)

    config = get_config()
    logging.basicConfig(
        filename=config['command-log-file'],
        level=logging.INFO,
        format="%(asctime)s: %(name)s@%(levelname)s %(message)s")
    results_log = logging.getLogger('juju-gui')
Example #2
0
def _setupLogging():
    global results_log
    if results_log is not None:
        return

    # Make sure that the root logger isn't configured already. If it does,
    # this basicConfig will be a noop and not setup the expected file handler
    # on the logger.
    root_logger = logging.getLogger()
    for handler in root_logger.handlers[:]:
        root_logger.removeHandler(handler)

    config = get_config()
    logging.basicConfig(
        filename=config['command-log-file'],
        level=logging.INFO,
        format="%(asctime)s: %(name)s@%(levelname)s %(message)s")
    results_log = logging.getLogger('juju-gui')
Example #3
0
def main():
    # Run pre-install tasks, if available.
    if os.path.isdir('exec.d'):
        dirnames = os.listdir('exec.d')
        dirnames.sort()
        for module in dirnames:
            filename = os.path.join('exec.d', module, 'charm-pre-install')
            try:
                run(filename)
            except OSError, e:
                # If the exec.d file does not exist or is not runnable or
                # is not a directory, assume we can recover.  Log the problem
                # and proceed.  Note that Juju Core has a special need of
                # errno.ENOTDIR because it apparently adds a ".empty" file in
                # empty charm directories, so trying to run
                # ./exec.d/.empty/charm-pre-install will trigger that error.
                if e.errno in (errno.ENOENT, errno.EACCES, errno.ENOTDIR):
                    log('{}: {}'.format(e.strerror, filename))
                else:
                    raise
    config = get_config()
    backend = Backend(config)
    backend.install()
    # Store current configuration.
    config_json.set(config)


if __name__ == '__main__':
    with log_hook():
        main()
Example #4
0
def get_port():
    """Return the current port the GUI server is listening to."""
    config = get_config()
    default_port = 443 if config['secure'] else 80
    return config.get('port', default_port) or default_port
Example #5
0
def get_port():
    """Return the current port the GUI server is listening to."""
    config = get_config()
    default_port = 443 if config['secure'] else 80
    return config.get('port', default_port) or default_port