Added I18N support for Xen-API error codes.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
This commit is contained in:
Ewan Mellor committed 2006-12-23 11:24:10 +00:00
1 parent 055785c1c8
commit 8ecdc794ab
4 files changed
+96 -4

No files matched your search

+12 -2
View File
@@ -7,16 +7,26 @@ all: build
.PHONY: build
build:
CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build
for file in `cd xen/xm; find messages -name xen-xm.po`; do \
dest=`echo "build/$$file" | \
sed -e 's#xen-xm.po#LC_MESSAGES/xen-xm.mo#'`; \
mkdir -p `dirname "$$dest"`; \
msgfmt -c -o "$$dest" "xen/xm/$$file"; \
done
.PHONY: install
ifndef XEN_PYTHON_NATIVE_INSTALL
install: all
install: install-messages
CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" --force
else
install: all
install: install-messages
CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --force
endif
install-messages: all
mkdir -p "$(DESTDIR)/usr/share/locale"
cp -R build/messages/* "$(DESTDIR)/usr/share/locale/"
.PHONY: test
test:
export LD_LIBRARY_PATH=$$(readlink -f ../libxc):$$(readlink -f ../xenstore); python test.py -b -u
+16 -1
View File
@@ -44,17 +44,32 @@
# OF THIS SOFTWARE.
# --------------------------------------------------------------------
import gettext
import xmlrpclib
import xen.util.xmlrpclib2
gettext.install('xen-xm')
class Failure(Exception):
def __init__(self, details):
self.details = details
def __str__(self):
return "Xen-API failure: %s" % str(self.details)
try:
return _(self.details[0]) % self._details_map()
except TypeError, exn:
return "Message database broken: %s.\nXen-API failure: %s" % \
(exn, str(self.details))
except Exception, exn:
import sys
print >>sys.stderr, exn
return "Xen-API failure: %s" % str(self.details)
def _details_map(self):
return dict([(str(i), self.details[i])
for i in range(len(self.details))])
class Session(xen.util.xmlrpclib2.ServerProxy):
+1 -1
View File
@@ -1780,7 +1780,7 @@ def _run_cmd(cmd, cmd_name, args):
except SystemExit, code:
return code == 0, code
except XenAPI.Failure, exn:
err(str(exn))
print >>sys.stderr, str(exn)
except xmlrpclib.Fault, ex:
if ex.faultCode == XendClient.ERROR_INVALID_DOMAIN:
err("Domain '%s' does not exist." % ex.faultString)
+67
View File
@@ -0,0 +1,67 @@
# ============================================================================
# This library is free software; you can redistribute it and/or
# modify it under the terms of version 2.1 of the GNU Lesser General Public
# License as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# ============================================================================
# Copyright (c) 2006 XenSource Inc.
# ============================================================================
#
#
msgid ""
msgstr ""
"Project-Id-Version: Xen-xm 3.0\n"
"PO-Revision-Date: 2006-12-23 11:04+0000\n"
"Last-Translator: Ewan Mellor <ewan@xensource.com>\n"
"Language-Team: xen-devel <xen-devel@lists.xensource.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ASCII\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "INTERNAL_ERROR"
msgstr "Internal error: %(1)s."
msgid "MAP_DUPLICATE_KEY"
msgstr "This map already contains %(1)s -> %(2)s."
msgid "MESSAGE_METHOD_UNKNOWN"
msgstr "The method %(1)s is unsupported."
msgid "MESSAGE_PARAMETER_COUNT_MISMATCH"
msgstr "The method %(1)s takes %(2)s argument(s) (%(3)s given)."
msgid "SESSION_AUTHENTICATION_FAILED"
msgstr "Permission denied."
msgid "HOST_CPU_HANDLE_INVALID"
msgstr "The host_cpu handle %(1)s is invalid."
msgid "HOST_HANDLE_INVALID"
msgstr "The host handle %(1)s is invalid."
msgid "SR_HANDLE_INVALID"
msgstr "The SR handle %(1)s is invalid."
msgid "VBD_HANDLE_INVALID"
msgstr "The VBD handle %(1)s is invalid."
msgid "VDI_HANDLE_INVALID"
msgstr "The VDI handle %(1)s is invalid."
msgid "VIF_HANDLE_INVALID"
msgstr "The VIF handle %(1)s is invalid."
msgid "VM_HANDLE_INVALID"
msgstr "The VM handle %(1)s is invalid."
msgid "VTPM_HANDLE_INVALID"
msgstr "The VTPM handle %(1)s is invalid."
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.