Hello, Am Donnerstag, 12. September 2013 schrieb Christian Boltz: > to make testing Kshitij's new tools easier, I propose to merge his > code in utils/apparmor/__init__.py - that's the only filename > conflict (at least in the 2.8 branch). If we do this, we can ship his > new tools in a testing package that can be installed on top of the > 2.8.x packages without problems [1]. > > The following patch is for trunk and the 2.8 branch:
As usual ;-) I found a way to break it - using "LANG=C" caused an exception because "C" is shorter than what filename = ...[0:2] expects. Here's an updated patch. Changes: - filename = ... moved into the try block - catch all exceptions, not only IOError I know it's not perfect, but worst thing that can happen is to get the non-translated interface. That's much better than an exception ;-) === modified file 'utils/apparmor/__init__.py' --- utils/apparmor/__init__.py 2012-05-08 05:37:48 +0000 +++ utils/apparmor/__init__.py 2013-09-12 15:10:50 +0000 @@ -1,9 +1,25 @@ # ------------------------------------------------------------------ # # Copyright (C) 2011-2012 Canonical Ltd. +# Copyright (C) 2013 Kshitij Gupta # # This program is free software; you can redistribute it and/or # modify it under the terms of version 2 of the GNU General Public # License published by the Free Software Foundation. # # ------------------------------------------------------------------ + +import gettext +import locale + +def init_localisation(): + locale.setlocale(locale.LC_ALL, '') + #cur_locale = locale.getlocale() + try: + filename = '/usr/share/locale/%s/LC_MESSAGES/apparmor-utils.mo' % locale.getlocale()[0][0:2] + trans = gettext.GNUTranslations(open( filename, 'rb')) + except: # IOError: + trans = gettext.NullTranslations() + trans.install() + +init_localisation() > Note that the Canonical copyright header in __init.py__ was > basically for the empty file - I'm not sure if it makes sense to keep > it ;-) (but I won't remove it unless explicitely asked to do so to > avoid Canonical will sue me for stealing an (besides the copyright > header) empty file ;-) > > Also note that trunk also needs changes in utils/apparmor/common.py - > Kshitij added several functions there. But that's another story and > not too urgent. However we should do it before the 3.0 release. > [1] We'll need to re-add the .py suffix for the tools in the testing > package, but that's another story ;-) BTW: I'll also commit this patch to openSUSE Factory which has feature freeze today ;-) Regards, Christian Boltz -- > Jan, I can write scripts too :) rebuild_logic="coolo" [> Stephan Kulow and Marcus Meissner in opensuse-factory] -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor