cas | 42 +++++++++++++++++++++++-------------------
lib/cas/utilities.py | 8 ++++----
version | 2 +-
3 files changed, 28 insertions(+), 24 deletions(-)
New commits:
commit bf425bd75095b2d12ea91f16990d2f74a2997437
Author: Adam Stokes <adam(a)conans.battleaxe>
Date: Thu Oct 23 11:41:30 2008 -0400
rpmutils is failing to capture all extracted kernels from stdout, needs fixing
diff --git a/cas b/cas
index 88a9074..007878c 100755
--- a/cas
+++ b/cas
@@ -8,6 +8,7 @@ import ConfigParser
import shutil
from cas.utilities import Utilities, CoreTool, dprint, sprint
+from cas.rpmutils import Tools
if sys.version_info[:2] < (2,4):
raise SystemExit("Python >= 2.4 required")
@@ -36,25 +37,29 @@ class CoreHandler(object):
corepath = self.tool.extractCore(self.filename, self.dst)
if corepath:
return os.path.realpath(corepath)
- return False
+ else:
+ dprint("Unable to determine corefile", DPRINT)
+ raise sys.exit(1)
class TimestampHandler(object):
- def __init__(self, corefile, db):
+ def __init__(self, corefile):
self.corefile = corefile
- self.db = db
self.util = Utilities()
self.tool = CoreTool()
def run(self):
- rpmDB = self.util.load(self.db)
+ rpmDB = self.util.load(RPMS)
coreTimestamp = self.tool.timestamp(self.corefile)
if coreTimestamp:
dprint(coreTimestamp, DPRINT)
- for k,v in rpmDB:
- if coreTimestamp and coreTimestamp in rpmDB[k].coreObj.timestamp:
- return rpmDB[k]
+ for k,v in rpmDB.iteritems():
+ if rpmDB[k].timestamp and coreTimestamp in rpmDB[k].timestamp:
+ return (k, rpmDB[k].debugKernel)
+ else:
+ dprint("Unable to match fingerprint : %s" %
(coreTimestamp,), DPRINT)
+ sys.exit(1)
else:
- dprint("Unable to match fingerprint : %s" % (coreTimestamp,),
DPRINT)
+ dprint("Cannot process a timestamp from: %s" % (self.corefile,),
DPRINT)
sys.exit(1)
return False
@@ -62,6 +67,7 @@ class CasApplication(object):
def __init__(self, args):
self.parse_options(args)
self.tool = Utilities()
+ self.rpmTool = Tools()
def parse_options(self, args):
parser = optparse.OptionParser(usage="cas -i ID "
@@ -86,23 +92,21 @@ class CasApplication(object):
if not os.path.isdir(self.storagePath):
os.makedirs(self.storagePath)
corefile = CoreHandler(self.filename, self.storagePath).run()
- if not corefile:
- dprint("Unable to determine corefile : %s" % (corefile,), DPRINT)
- sys.exit(1)
- coreObj = TimestampHandler(corefile, RPMS).run()
- try:
- # extract debug kernel to workDirectory
- except:
- dprint("Unable to perform symlink %s" % (os.path.basename(debug)),
DPRINT)
- sys.exit(1)
+ debuginfo, debugKernel = TimestampHandler(corefile).run()
+ filterString = "*/%s" % (debugKernel,)
+ self.rpmTool.extract(debuginfo, self.storagePath,
+ filter=filterString,
+ return_results=False)
- crash_cmd = "/bin/sh\ncrash %s %s" % (symlink_dst, corefile)
+ crash_cmd = "#!/bin/sh\ncrash %s %s\n" %
(os.path.join(self.storagePath,
+ debugKernel),
+ corefile)
crash_exe = os.path.join(self.storagePath,"crash")
fh = open(crash_exe,"w")
fh.write(crash_cmd)
fh.close()
self.tool.make_exe(crash_exe)
- dprint("Job on %s complete and located in %s." %
(self.filename,self.storagePath), DPRINT)
+ print("Job on %s complete and located in %s." %
(self.filename,self.storagePath))
return
if __name__=="__main__":
diff --git a/lib/cas/utilities.py b/lib/cas/utilities.py
old mode 100644
new mode 100755
index 9b40d59..a9bea61
--- a/lib/cas/utilities.py
+++ b/lib/cas/utilities.py
@@ -20,7 +20,7 @@ logging.basicConfig(level=logging.DEBUG,
def dprint(msg, debug=True):
if debug:
sys.stderr.write("(debug) %s" % (msg,))
- logging.error(msg)
+ logging.debug(msg)
def sprint(msg):
""" function to print status messages
@@ -182,7 +182,7 @@ class CoreTool(object):
self.dst = dst
self.filepath = filepath
if not tarfile.is_tarfile(self.filepath):
- raise CoreException("%s : is not a properly compressed tarfile." %
(self.filepath,))
+ raise CoreException("%s : is not a properly compressed tarfile." %
(self.filepath,))
else:
tar = tarfile.open(self.filepath, "r")
tar.extractall(self.dst)
@@ -207,10 +207,10 @@ class CoreTool(object):
def timestamp(self, path):
""" captures fingerprint from core
"""
- match='Linux\sversion.*\d{1,4}|#1\s.*\d{1,2}'
+ match='Linux\sversion.*20\d{1,2}|#1\s.*20\d{1,2}'
try:
fd=open('%s' % (path))
- except IOError:
+ except IOError:
return False
fd.seek(0)
b = os.read(fd.fileno(),54000000)
diff --git a/version b/version
index 1312e50..d4d75d0 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-0.13 64
+0.13 65