From a95eaeac8e07b8ccd173b0f408575cc9a0d508fc Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Wed, 4 Jul 2012 08:52:47 -0400 Subject: Internationalization for public errors Currently, we throw many public exceptions without proper i18n. Wrap natural-language error messages in _() so they can be translated. In the service plugin, raise NotFound errors using handle_not_found helper so the error message contains the offending service. Use ScriptError instead of NotFoundError in bindinstance install. https://fedorahosted.org/freeipa/ticket/1953 --- ipaserver/install/bindinstance.py | 7 +++++-- ipaserver/install/certs.py | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'ipaserver/install') diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py index 2e00f70b..8284f3ea 100644 --- a/ipaserver/install/bindinstance.py +++ b/ipaserver/install/bindinstance.py @@ -35,6 +35,7 @@ from ipalib.parameters import IA5Str from ipalib.util import (validate_zonemgr, normalize_zonemgr, get_dns_forward_zone_update_policy, get_dns_reverse_zone_update_policy) from ipapython.ipa_log_manager import * +from ipalib.text import _ import ipalib from ipalib import api, util, errors @@ -277,7 +278,8 @@ def add_zone(name, zonemgr=None, dns_backup=None, ns_hostname=None, ns_ip_addres # automatically retrieve list of DNS masters dns_masters = api.Object.dnsrecord.get_dns_masters() if not dns_masters: - raise errors.NotFound("No IPA server with DNS support found!") + raise installutils.ScriptError( + "No IPA server with DNS support found!") ns_main = dns_masters.pop(0) ns_replicas = dns_masters addresses = resolve_host(ns_main) @@ -321,7 +323,8 @@ def add_reverse_zone(zone, ns_hostname=None, ns_ip_address=None, # automatically retrieve list of DNS masters dns_masters = api.Object.dnsrecord.get_dns_masters() if not dns_masters: - raise errors.NotFound("No IPA server with DNS support found!") + raise installutils.ScriptError( + "No IPA server with DNS support found!") ns_main = dns_masters.pop(0) ns_replicas = dns_masters addresses = resolve_host(ns_main) diff --git a/ipaserver/install/certs.py b/ipaserver/install/certs.py index eebaa48c..f0f0f1df 100644 --- a/ipaserver/install/certs.py +++ b/ipaserver/install/certs.py @@ -41,6 +41,7 @@ from ipapython import services as ipaservices from ipalib import x509 from ipapython.dn import DN from ipalib.errors import CertificateOperationError +from ipalib.text import _ from nss.error import NSPRError import nss.nss as nss @@ -663,8 +664,9 @@ class CertDB(object): dogtag.https_request(self.host_name, api.env.ca_ee_install_port, "/ca/ee/ca/profileSubmitSSLClient", self.secdir, password, "ipaCert", **params) if http_status != 200: - raise CertificateOperationError(error='Unable to communicate with CMS (%s)' % \ - http_reason_phrase) + raise CertificateOperationError( + error=_('Unable to communicate with CMS (%s)') % + http_reason_phrase) # The result is an XML blob. Pull the certificate out of that doc = xml.dom.minidom.parseString(http_body) -- cgit