aboutsummaryrefslogtreecommitdiffstats
path: root/src/sosreport
diff options
context:
space:
mode:
authorshnavid <shnavid@ef72aa8b-4018-0410-8976-d6e080ef94d8>2007-07-14 11:07:37 +0000
committershnavid <shnavid@ef72aa8b-4018-0410-8976-d6e080ef94d8>2007-07-14 11:07:37 +0000
commitf78567b537bd40f6112e051f7206ad36cc5d9828 (patch)
tree909cf78536dd1cf402737ca5328c619eb75e9322 /src/sosreport
parent1596f54d8ad39160f995798f457c759c67c79494 (diff)
downloadsos-f78567b537bd40f6112e051f7206ad36cc5d9828.tar.gz
* initial language localization support
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@204 ef72aa8b-4018-0410-8976-d6e080ef94d8
Diffstat (limited to 'src/sosreport')
-rwxr-xr-xsrc/sosreport51
1 files changed, 28 insertions, 23 deletions
diff --git a/src/sosreport b/src/sosreport
index c615393d..cc86fae7 100755
--- a/src/sosreport
+++ b/src/sosreport
@@ -38,6 +38,7 @@ import logging
from stat import *
from time import strftime, localtime, time
from pwd import getpwuid
+import gettext
__version__ = 1.7
@@ -352,6 +353,11 @@ def sosreport():
os.mkdir(logdir, 0755)
os.mkdir(rptdir, 0755)
+ # initialize i18n
+ gettext.install('sos', './locale', unicode=False)
+ presLan_en = gettext.translation("sos", 'locale', languages=['en'])
+ presLan_en.install()
+
# initialize logging
soslog = logging.getLogger('sos')
soslog.setLevel(logging.DEBUG)
@@ -384,15 +390,14 @@ def sosreport():
# set up dict so everyone can share the following
commons = {'dstroot': dstroot, 'cmddir': cmddir, 'logdir': logdir, 'rptdir': rptdir,
'soslog': soslog, 'policy': policy, 'verbosity' : __cmdLineOpts__.verbosity,
- 'xmlreport' : xmlrep }
-
+ 'xmlreport' : xmlrep }
# Make policy aware of the commons
policy.setCommons(commons)
- sys.stdout.write("\n")
- soslog.info("sosreport (version %s)" % (__version__) )
- sys.stdout.write("\n")
+ print
+ soslog.info ( _("sosreport (version %s)") % __version__)
+ print
# generate list of available plugins
plugins = os.listdir(pluginpath)
@@ -409,15 +414,15 @@ def sosreport():
if policy.validatePlugin(pluginpath + plug):
pluginClass = importPlugin("sos.plugins." + plugbase, plugbase)
else:
- soslog.warning("plugin %s does not validate, skipping" % plug)
+ soslog.warning(_("plugin %s does not validate, skipping") % plug)
skippedplugins.append((plugbase, pluginClass(plugbase, commons)))
continue
if plugbase in __cmdLineOpts__.noplugins:
- soslog.log(logging.VERBOSE, "plug %s skipped (noplugins)" % plugbase)
+ soslog.log(logging.VERBOSE, _("plug %s skipped (noplugins)") % plugbase)
skippedplugins.append((plugbase, pluginClass(plugbase, commons)))
continue
if not pluginClass(plugbase, commons).checkenabled() and not plugbase in __cmdLineOpts__.enableplugins and not plugbase in __cmdLineOpts__.onlyplugins:
- soslog.log(logging.VERBOSE, "plugin %s is inactive (use -e or -o to enable)." % plug)
+ soslog.log(logging.VERBOSE, _("plugin %s is inactive (use -e or -o to enable).") % plug)
skippedplugins.append((plugbase, pluginClass(plugbase, commons)))
continue
if not pluginClass(plugbase, commons).defaultenabled() and not plugbase in __cmdLineOpts__.enableplugins and not plugbase in __cmdLineOpts__.onlyplugins:
@@ -425,43 +430,43 @@ def sosreport():
skippedplugins.append((plugbase, pluginClass(plugbase, commons)))
continue
if __cmdLineOpts__.onlyplugins and not plugbase in __cmdLineOpts__.onlyplugins:
- soslog.log(logging.VERBOSE, "plugin %s not specified in --onlyplugin list" % plug)
+ soslog.log(logging.VERBOSE, _("plugin %s not specified in --onlyplugin list") % plug)
skippedplugins.append((plugbase, pluginClass(plugbase, commons)))
continue
loadedplugins.append((plugbase, pluginClass(plugbase, commons)))
except:
- soslog.warning("Plugin %s does not install, skipping" % plug)
+ soslog.warning(_("Plugin %s does not install, skipping") % plug)
raise
except:
- soslog.warning("plugin load failed for %s" % plug)
+ soslog.warning(_("plugin load failed for %s") % plug)
if __raisePlugins__:
raise
# First, gather and process options
for plugname, plug in loadedplugins:
- soslog.log(logging.VERBOSE3, "processing options from plugin: %s" % plugname)
+ soslog.log(logging.VERBOSE3, _("processing options from plugin: %s") % plugname)
names, parms = plug.getAllOptions()
for optname, optparm in zip(names, parms):
alloptions.append((plug, plugname, optname, optparm))
if __cmdLineOpts__.listPlugins:
if not len(loadedplugins) and not len(skippedplugins):
- soslog.error("no valid plugins found")
+ soslog.error(_("no valid plugins found"))
sys.exit(1)
- print "The following plugins are currently enabled:"
+ print _("The following plugins are currently enabled:")
print
for (plugname,plug) in loadedplugins:
print " %-25s %s" % (plugname,plug.get_description())
print
- print "The following plugin options are available:"
+ print _("The following plugin options are available:")
print
for (plug, plugname, optname, optparm) in alloptions:
print " %-25s %s [%d]" % (plugname + "." + optname, optparm["desc"], optparm["enabled"])
print
- print "The following plugins are currently disabled:"
+ print _("The following plugins are currently disabled:")
print
for (plugname,plugclass) in skippedplugins:
print " %-25s %s" % (plugname,plugclass.get_description())
@@ -472,18 +477,18 @@ def sosreport():
# to go anywhere further than listing the plugins we will need root permissions.
#
if os.getuid() != 0:
- print 'sosreport requires root permissions to run.'
+ print _('sosreport requires root permissions to run.')
sys.exit(1)
# we don't need to keep in memory plugins we are not going to use
del skippedplugins
if not len(loadedplugins):
- soslog.error("no valid plugins were enabled")
+ soslog.error(_("no valid plugins were enabled"))
sys.exit(1)
try:
- raw_input("""This utility will collect some detailed information about the
+ raw_input(_("""This utility will collect some detailed information about the
hardware and setup of your Red Hat Enterprise Linux system.
This information will be used to diagnose problems with your
system and will be considered confidential information.
@@ -493,7 +498,7 @@ This process may take a while to complete.
No changes will be made to your system.
Press ENTER to continue, or CTRL-C to quit.
-""")
+"""))
except KeyboardInterrupt:
print
sys.exit(0)
@@ -521,7 +526,7 @@ Press ENTER to continue, or CTRL-C to quit.
try:
get_curse_options(alloptions)
except "Cancelled":
- sys.exit("Exiting.")
+ sys.exit(_("Exiting."))
elif __cmdLineOpts__.fastoptions:
for i in range(len(alloptions)):
for plug, plugname, optname, optparm in alloptions:
@@ -668,8 +673,8 @@ Press ENTER to continue, or CTRL-C to quit.
plug.postproc()
if __cmdLineOpts__.gatheronly:
- soslog.info("Collected information is in " + dstroot)
- soslog.info("Your html report is in " + rptdir + "/" + "sosreport.html")
+ soslog.info(_("Collected information is in ") + dstroot)
+ soslog.info(_("Your html report is in ") + rptdir + "/" + "sosreport.html")
else:
# package up the results for the support organization
policy.packageResults()