Пример #1
0
    def test_get_config(self):
        # get_config returns the contents of the current charm
        # configuration, as returned by config-get --format=json.
        mock_config = {'key': 'value'}

        # Monkey-patch shelltoolbox.command to avoid having to call out
        # to config-get.
        self._patch_command(lambda: dumps(mock_config))
        self.assertEqual(mock_config, charmhelpers.get_config())
Пример #2
0
    def test_get_config(self):
        # get_config returns the contents of the current charm
        # configuration, as returned by config-get --format=json.
        mock_config = {'key': 'value'}

        # Monkey-patch shelltoolbox.command to avoid having to call out
        # to config-get.
        self._patch_command(lambda: dumps(mock_config))
        self.assertEqual(mock_config, charmhelpers.get_config())
Пример #3
0
def _setupLogging():
    global results_log
    if results_log is not None:
        return
    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')
Пример #4
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')
Пример #5
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')
Пример #6
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
Пример #7
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