How to use the zulip.zulip.__init__.ZulipError 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 / zulip / __init__.py View on Github external
def get_default_config_filename():
    # type: () -> Optional[str]
    if os.environ.get("HOME") is None:
        return None

    config_file = os.path.join(os.environ["HOME"], ".zuliprc")
    if (not os.path.exists(config_file) and
            os.path.exists(os.path.join(os.environ["HOME"], ".humbugrc"))):
        raise ZulipError("The Zulip API configuration file is now ~/.zuliprc; please run:\n\n"
                         "  mv ~/.humbugrc ~/.zuliprc\n")
    return config_file
github zulip / python-zulip-api / zulip / zulip / __init__.py View on Github external
field = field.lower()

    if field == "true":
        return True
    elif field == "false":
        return False
    else:
        return None

class ZulipError(Exception):
    pass

class ConfigNotFoundError(ZulipError):
    pass

class MissingURLError(ZulipError):
    pass

class UnrecoverableNetworkError(ZulipError):
    pass

class Client(object):
    def __init__(self, email=None, api_key=None, config_file=None,
                 verbose=False, retry_on_errors=True,
                 site=None, client=None,
                 cert_bundle=None, insecure=None,
                 client_cert=None, client_cert_key=None):
        # type: (Optional[str], Optional[str], Optional[str], bool, bool, Optional[str], Optional[str], Optional[str], Optional[bool], Optional[str], Optional[str]) -> None
        if client is None:
            client = _default_client()

        # Normalize user-specified path
github zulip / python-zulip-api / zulip / zulip / __init__.py View on Github external
return True
    elif field == "false":
        return False
    else:
        return None

class ZulipError(Exception):
    pass

class ConfigNotFoundError(ZulipError):
    pass

class MissingURLError(ZulipError):
    pass

class UnrecoverableNetworkError(ZulipError):
    pass

class Client(object):
    def __init__(self, email=None, api_key=None, config_file=None,
                 verbose=False, retry_on_errors=True,
                 site=None, client=None,
                 cert_bundle=None, insecure=None,
                 client_cert=None, client_cert_key=None):
        # type: (Optional[str], Optional[str], Optional[str], bool, bool, Optional[str], Optional[str], Optional[str], Optional[bool], Optional[str], Optional[str]) -> None
        if client is None:
            client = _default_client()

        # Normalize user-specified path
        if config_file is not None:
            config_file = os.path.abspath(os.path.expanduser(config_file))
        # Fill values from Environment Variables if not available in Constructor
github zulip / python-zulip-api / zulip / zulip / __init__.py View on Github external
site = config.get("api", "site")
            if client_cert is None and config.has_option("api", "client_cert"):
                client_cert = config.get("api", "client_cert")
            if client_cert_key is None and config.has_option("api", "client_cert_key"):
                client_cert_key = config.get("api", "client_cert_key")
            if cert_bundle is None and config.has_option("api", "cert_bundle"):
                cert_bundle = config.get("api", "cert_bundle")
            if insecure is None and config.has_option("api", "insecure"):
                # Be quite strict about what is accepted so that users don't
                # disable security unintentionally.
                insecure_setting = config.get('api', 'insecure')

                insecure = validate_boolean_field(insecure_setting)

                if insecure is None:
                    raise ZulipError("insecure is set to '{}', it must be "
                                     "'true' or 'false' if it is used in {}"
                                     .format(insecure_setting, config_file))

        elif None in (api_key, email):
            raise ConfigNotFoundError("api_key or email not specified and file %s does not exist"
                                      % (config_file,))

        assert(api_key is not None and email is not None)
        self.api_key = api_key
        self.email = email
        self.verbose = verbose
        if site is not None:
            if site.startswith("localhost"):
                site = "http://" + site
            elif not site.startswith("http"):
                site = "https://" + site
github zulip / python-zulip-api / zulip / zulip / __init__.py View on Github external
if not isinstance(field, str):
        return None

    field = field.lower()

    if field == "true":
        return True
    elif field == "false":
        return False
    else:
        return None

class ZulipError(Exception):
    pass

class ConfigNotFoundError(ZulipError):
    pass

class MissingURLError(ZulipError):
    pass

class UnrecoverableNetworkError(ZulipError):
    pass

class Client(object):
    def __init__(self, email=None, api_key=None, config_file=None,
                 verbose=False, retry_on_errors=True,
                 site=None, client=None,
                 cert_bundle=None, insecure=None,
                 client_cert=None, client_cert_key=None):
        # type: (Optional[str], Optional[str], Optional[str], bool, bool, Optional[str], Optional[str], Optional[str], Optional[bool], Optional[str], Optional[str]) -> None
        if client is None: