diff options
-rw-r--r-- | src/Makefile | 3 | ||||
-rw-r--r-- | src/TODO | 2 | ||||
-rw-r--r-- | src/lib/sos/plugintools.py | 26 | ||||
-rw-r--r-- | src/locale/en/LC_MESSAGES/sos.po | 99 | ||||
-rwxr-xr-x | src/sosreport | 51 |
5 files changed, 146 insertions, 35 deletions
diff --git a/src/Makefile b/src/Makefile index 057060fd..c7564b88 100644 --- a/src/Makefile +++ b/src/Makefile @@ -83,3 +83,6 @@ rpm: rpmbuild -ba --define="_topdir $(TOPDIR)" sos.spec @mv $(TOPDIR)/RPMS/noarch/$(NAME)-$(VERSION)*.rpm $(TOPDIR)/SRPMS/$(NAME)-$(VERSION)*.rpm $(TOPDIR)/SOURCES/$(NAME)-$(VERSION).tar.gz dist/ + +pot: + python tools/pygettext.py -o locale/sos.pot sosreport @@ -5,6 +5,8 @@ To Do List: * Choose sane defaults to satisfy Red Hat support requirements (ie. what plugins should be loaded by default, with what options, etc) + * Display on screen what files/commands are being gathered. + * Make sosreport a drop-in replacement for sysreport * Allow to use a different rootdir than / diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py index 1dac3987..930a4d17 100644 --- a/src/lib/sos/plugintools.py +++ b/src/lib/sos/plugintools.py @@ -60,6 +60,8 @@ class PluginBase: self.thread = None self.eta_weight = 1 + self.soslog = logging.getLogger('sos') + # get the option list into a dictionary for opt in self.optionList: self.optNames.append(opt[0]) @@ -87,7 +89,7 @@ class PluginBase: except KeyboardInterrupt: raise KeyboardInterrupt except Exception, e: - self.cInfo['soslog'].log(logging.VERBOSE, "Problem at path %s (%s)\n" % (abspath,e)) + self.soslog.log(logging.VERBOSE, "Problem at path %s (%s)\n" % (abspath,e)) break return False @@ -143,7 +145,7 @@ class PluginBase: except KeyboardInterrupt: raise KeyboardInterrupt except Exception, e: - self.cInfo['soslog'].log(logging.VERBOSE, "Problem at path %s (%s)" % (srcpath+'/'+afile, e)) + self.soslog.log(logging.VERBOSE, "Problem at path %s (%s)" % (srcpath+'/'+afile, e)) # if on forbidden list, abspath is null if not abspath == '': dstslname = sosRelPath(self.cInfo['rptdir'], abspath) @@ -158,13 +160,13 @@ class PluginBase: except KeyboardInterrupt: raise KeyboardInterrupt except Exception, e: - self.cInfo['soslog'].log(logging.VERBOSE, "Problem at path %s (%s)" % (srcpath, e)) + self.soslog.log(logging.VERBOSE, "Problem at path %s (%s)" % (srcpath, e)) return abspath else: if not os.path.exists(srcpath): - self.cInfo['soslog'].debug("File or directory %s does not exist\n" % srcpath) + self.soslog.debug("File or directory %s does not exist\n" % srcpath) elif os.path.isdir(srcpath): for afile in os.listdir(srcpath): if afile == '.' or afile == '..': @@ -185,7 +187,7 @@ class PluginBase: # pylint: disable-msg = W0612 status, shout, runtime = sosGetCommandOutput("/bin/cp --parents -P --preserve=mode,ownership,timestamps,links " + src +" " + self.cInfo['dstroot']) if status: - self.cInfo['soslog'].debug(shout) + self.soslog.debug(shout) abspath = os.path.join(self.cInfo['dstroot'], src.lstrip(os.path.sep)) relpath = sosRelPath(self.cInfo['rptdir'], abspath) return relpath, abspath @@ -194,7 +196,7 @@ class PluginBase: except KeyboardInterrupt: raise KeyboardInterrupt except Exception,e: - self.cInfo['soslog'].warning("Problem copying file %s (%s)" % (src, e)) + self.soslog.warning("Problem copying file %s (%s)" % (src, e)) def addForbiddenPath(self, forbiddenPath): """Specify a path to not copy, even if it's part of a copyPaths[] entry. @@ -273,7 +275,7 @@ class PluginBase: """ # Log if binary is not runnable or does not exist if not os.access(prog.split()[0], os.X_OK): - self.cInfo['soslog'].log(logging.VERBOSE, "binary '%s' does not exist or is not runnable" % prog.split()[0]) + self.soslog.log(logging.VERBOSE, "binary '%s' does not exist or is not runnable" % prog.split()[0]) # pylint: disable-msg = W0612 status, shout, runtime = sosGetCommandOutput(prog) @@ -318,7 +320,7 @@ class PluginBase: """ # First check to make sure the binary exists and is runnable. if not os.access(exe.split()[0], os.X_OK): - self.cInfo['soslog'].log(logging.VERBOSE2, "Binary '%s' does not exist or is not runnable" % exe.split()[0]) + self.soslog.log(logging.VERBOSE2, "Binary '%s' does not exist or is not runnable" % exe.split()[0]) return # pylint: disable-msg = W0612 @@ -402,7 +404,7 @@ class PluginBase: Collect the data for a plugin """ for path in self.copyPaths: - self.cInfo['soslog'].debug("copying pathspec %s" % path) + self.soslog.debug("copying pathspec %s" % path) try: self.doCopyFileOrDir(path) except SystemExit: @@ -410,9 +412,9 @@ class PluginBase: except KeyboardInterrupt: raise KeyboardInterrupt except Exception, e: - self.cInfo['soslog'].log(logging.VERBOSE, "Error copying from pathspec %s (%s)" % (path,e)) + self.soslog.log(logging.VERBOSE, "Error copying from pathspec %s (%s)" % (path,e)) for (prog,suggest_filename,root_symlink) in self.collectProgs: - self.cInfo['soslog'].debug("collecting output of '%s'" % prog) + self.soslog.debug("collecting output of '%s'" % prog) try: self.collectOutputNow(prog, suggest_filename, root_symlink) except SystemExit: @@ -420,7 +422,7 @@ class PluginBase: except KeyboardInterrupt: raise KeyboardInterrupt except: - self.cInfo['soslog'].log(logging.VERBOSE, "Error collecting output of '%s'" % prog,) + self.soslog.log(logging.VERBOSE, "Error collecting output of '%s'" % prog,) def get_description(self): """ This function will return the description for the plugin""" diff --git a/src/locale/en/LC_MESSAGES/sos.po b/src/locale/en/LC_MESSAGES/sos.po new file mode 100644 index 00000000..c103a495 --- /dev/null +++ b/src/locale/en/LC_MESSAGES/sos.po @@ -0,0 +1,99 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR ORGANIZATION +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2007-07-14 11:57\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: utf-8\n" +"Generated-By: pygettext.py 1.5\n" + + +#: sosreport:399 +msgid "sosreport (version %s)" +msgstr "" + +#: sosreport:417 +msgid "plugin %s does not validate, skipping" +msgstr "" + +#: sosreport:421 +msgid "plug %s skipped (noplugins)" +msgstr "" + +#: sosreport:425 +msgid "plugin %s is inactive (use -e or -o to enable)." +msgstr "" + +#: sosreport:433 +msgid "plugin %s not specified in --onlyplugin list" +msgstr "" + +#: sosreport:438 +msgid "Plugin %s does not install, skipping" +msgstr "" + +#: sosreport:441 +msgid "plugin load failed for %s" +msgstr "" + +#: sosreport:447 +msgid "processing options from plugin: %s" +msgstr "" + +#: sosreport:454 +msgid "no valid plugins found" +msgstr "" + +#: sosreport:457 +msgid "The following plugins are currently enabled:" +msgstr "" + +#: sosreport:463 +msgid "The following plugin options are available:" +msgstr "" + +#: sosreport:469 +msgid "The following plugins are currently disabled:" +msgstr "" + +#: sosreport:480 +msgid "sosreport requires root permissions to run." +msgstr "" + +#: sosreport:487 +msgid "no valid plugins were enabled" +msgstr "" + +#: sosreport:491 +msgid "" +"This utility will collect some detailed information about the\n" +"hardware and setup of your Red Hat Enterprise Linux system.\n" +"This information will be used to diagnose problems with your \n" +"system and will be considered confidential information.\n" +"Red Hat will use this information for diagnostic purposes ONLY.\n" +"\n" +"This process may take a while to complete.\n" +"No changes will be made to your system.\n" +"\n" +"Press ENTER to continue, or CTRL-C to quit.\n" +msgstr "" + +#: sosreport:529 +msgid "Exiting." +msgstr "" + +#: sosreport:676 +msgid "Collected information is in " +msgstr "" + +#: sosreport:677 +msgid "Your html report is in " +msgstr "" + 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() |