How to use the zulip.integrations.bridge_with_matrix.matrix_bridge.Bridge_ConfigException function in zulip

To help you get started, we’ve selected a few zulip examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zulip / python-zulip-api / zulip / integrations / bridge_with_matrix / matrix_bridge.py View on Github external
def read_configuration(config_file):
    # type: (str) -> Dict[str, Dict[str, str]]
    config = configparser.ConfigParser()

    try:
        config.read(config_file)
    except configparser.Error as exception:
        raise Bridge_ConfigException(str(exception))

    if set(config.sections()) != {'matrix', 'zulip'}:
        raise Bridge_ConfigException("Please ensure the configuration has zulip & matrix sections.")

    # TODO Could add more checks for configuration content here

    return {section: dict(config[section]) for section in config.sections()}
github zulip / python-zulip-api / zulip / integrations / bridge_with_matrix / matrix_bridge.py View on Github external
def write_sample_config(target_path, zuliprc):
    # type: (str, Optional[str]) -> None
    if os.path.exists(target_path):
        raise Bridge_ConfigException("Path '{}' exists; not overwriting existing file.".format(target_path))

    sample_dict = OrderedDict((
        ('matrix', OrderedDict((
            ('host', 'https://matrix.org'),
            ('username', 'username'),
            ('password', 'password'),
            ('room_id', '#zulip:matrix.org'),
        ))),
        ('zulip', OrderedDict((
            ('email', 'glitch-bot@chat.zulip.org'),
            ('api_key', 'aPiKeY'),
            ('site', 'https://chat.zulip.org'),
            ('stream', 'test here'),
            ('topic', 'matrix'),
        ))),
    ))
github zulip / python-zulip-api / zulip / integrations / bridge_with_matrix / matrix_bridge.py View on Github external
('api_key', 'aPiKeY'),
            ('site', 'https://chat.zulip.org'),
            ('stream', 'test here'),
            ('topic', 'matrix'),
        ))),
    ))

    if zuliprc is not None:
        if not os.path.exists(zuliprc):
            raise Bridge_ConfigException("Zuliprc file '{}' does not exist.".format(zuliprc))

        zuliprc_config = configparser.ConfigParser()
        try:
            zuliprc_config.read(zuliprc)
        except configparser.Error as exception:
            raise Bridge_ConfigException(str(exception))

        # Can add more checks for validity of zuliprc file here

        sample_dict['zulip']['email'] = zuliprc_config['api']['email']
        sample_dict['zulip']['site'] = zuliprc_config['api']['site']
        sample_dict['zulip']['api_key'] = zuliprc_config['api']['key']

    sample = configparser.ConfigParser()
    sample.read_dict(sample_dict)
    with open(target_path, 'w') as target:
        sample.write(target)
github zulip / python-zulip-api / zulip / integrations / bridge_with_matrix / matrix_bridge.py View on Github external
def read_configuration(config_file):
    # type: (str) -> Dict[str, Dict[str, str]]
    config = configparser.ConfigParser()

    try:
        config.read(config_file)
    except configparser.Error as exception:
        raise Bridge_ConfigException(str(exception))

    if set(config.sections()) != {'matrix', 'zulip'}:
        raise Bridge_ConfigException("Please ensure the configuration has zulip & matrix sections.")

    # TODO Could add more checks for configuration content here

    return {section: dict(config[section]) for section in config.sections()}