diff options
author | shnavid <shnavid@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2007-07-12 10:34:13 +0000 |
---|---|---|
committer | shnavid <shnavid@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2007-07-12 10:34:13 +0000 |
commit | 0e230ba655658612220ecd2c317a3c5e9da240ce (patch) | |
tree | 8b2a15b5a0bf37db9c7ab5628e547c9948a5a3f6 /src/lib | |
parent | 4c6d1e7c6f01487d919c93c3bfb6592c0dc9b1c7 (diff) | |
download | sos-0e230ba655658612220ecd2c317a3c5e9da240ce.tar.gz |
* 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
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/sos/plugintools.py | 21 |
1 files changed, 20 insertions, 1 deletions
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 |