From 0e230ba655658612220ecd2c317a3c5e9da240ce Mon Sep 17 00:00:00 2001 From: shnavid Date: Thu, 12 Jul 2007 10:34:13 +0000 Subject: * added addCopySpecLimit() which copies files up to a max size limit * make output filenames more readable git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@198 ef72aa8b-4018-0410-8976-d6e080ef94d8 --- src/lib/sos/plugintools.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py index e54aa6a5..75ec033c 100644 --- a/src/lib/sos/plugintools.py +++ b/src/lib/sos/plugintools.py @@ -32,6 +32,7 @@ from sos.helpers import * from threading import Thread, activeCount import os, os.path, sys, string, itertools, glob, re import logging +from stat import * class PluginBase: """ @@ -223,6 +224,18 @@ class PluginBase: # nonexistent options aren't enabled. return 0 + def addCopySpecLimit(self,fname,sizelimit = None): + """Add a file specification (with limits) + """ + files = glob.glob(fname) + files.sort() + cursize = 0 + for flog in files: + cursize += os.stat(flog)[ST_SIZE] + if sizelimit and (cursize / 1024 / 1024) > sizelimit: + break + self.addCopySpec(flog) + def addCopySpec(self, copyspec): """ Add a file specification (can be file, dir,or shell glob) to be copied into the sosreport by this module @@ -285,9 +298,15 @@ class PluginBase: rawcmd = os.path.basename(exe).strip()[:28] # Mangle command to make it suitable for a file name - tabl = string.maketrans(" /\t;#$|%\"'`}{\n", "_._-----------") + tabl = string.maketrans(" /\t;#$|%\"'`}{\n", "--------------") mangledname = rawcmd.translate(tabl) + # remove double "--" + while True: + doublepos = mangledname.find("--") + if doublepos == -1: break + mangledname = mangledname[:doublepos] + mangledname[doublepos+2:] + outfn = self.cInfo['cmddir'] + "/" + self.piName + "/" + mangledname # check for collisions -- cgit