cas | 11 ++++++++--- lib/cas/utilities.py | 26 +++++++++++++++----------- version | 2 +- 3 files changed, 24 insertions(+), 15 deletions(-)
New commits: commit 7bb15d20e43a4f54280321940b608c0431e52b39 Author: Adam Stokes adam@conans.battleaxe Date: Thu Oct 30 12:02:04 2008 -0400
finalized on the downloader, altered cas to accept both localfiles and urlbased files.
support for http and ftp only at this time
diff --git a/cas b/cas index 95f1e11..1590628 100755 --- a/cas +++ b/cas @@ -7,7 +7,7 @@ import os import ConfigParser import shutil
-from cas.utilities import Utilities, CoreTool, dprint, sprint +from cas.utilities import Utilities, CoreTool, dprint, sprint, Download from cas.rpmutils import Tools
if sys.version_info[:2] < (2,4): @@ -27,6 +27,8 @@ class CoreHandler(object): self.tool = CoreTool()
def run(self): + if (self.filename.startswith("http") or self.filename.startswith("ftp")): + self.filename = Download(self.filename, self.dst).get() if not os.path.isfile(self.filename): print("Unable to find file %s" % (self.filename,)) sys.exit(1) @@ -50,6 +52,7 @@ class TimestampHandler(object): def run(self): rpmDB = self.util.load(RPMS) coreTimestamp = self.tool.timestamp(self.corefile) + dprint(coreTimestamp, DPRINT) if coreTimestamp: for k,v in rpmDB.iteritems(): for coreObj in rpmDB[k]: @@ -59,7 +62,8 @@ class TimestampHandler(object): else: dprint("Cannot process a timestamp from: %s" % (self.corefile,), DPRINT) sys.exit(1) - return False + dprint("Unable to match (%s,%s) with debugKernel" % (self.corefile, coreTimestamp), DPRINT) + sys.exit(1)
class CasApplication(object): def __init__(self, args): @@ -90,13 +94,14 @@ class CasApplication(object): if not os.path.isdir(self.storagePath): os.makedirs(self.storagePath) corefile = CoreHandler(self.filename, self.storagePath).run() + dprint(corefile, DPRINT) debuginfo, debugKernel = TimestampHandler(corefile).run() filterString = "*/%s" % (debugKernel,) self.rpmTool.extract(debuginfo, self.storagePath, filter=filterString, return_results=False)
- self.tool.buildCrashFile(self.storagePath, vmcore, debugKernel) + self.tool.buildCrashFile(self.storagePath, corefile, debugKernel) print("Job on %s complete and located in %s." % (self.filename,self.storagePath)) return
diff --git a/lib/cas/utilities.py b/lib/cas/utilities.py index 074b3c5..937d8c9 100755 --- a/lib/cas/utilities.py +++ b/lib/cas/utilities.py @@ -8,6 +8,7 @@ import sys import shutil import tarfile import logging +import urlparse import urlgrabber.grabber as grabber
from subprocess import Popen, PIPE @@ -181,8 +182,8 @@ class Utilities(object): # Build crash input file crashInputPath = os.path.join(dst, file_in) crashInputFH = open(crashInputPath, "w") - crashInFH.write(",".join(crashInputCmds)) - crashInFH.close() + crashInputFH.write("".join(crashInputCmds)) + crashInputFH.close()
vmcorePath = os.path.join(dst, vmcore) crashCmd = "#!/bin/sh\ncrash %s %s -i %s -s\n" % (vmcorePath,debug, @@ -210,8 +211,11 @@ class CoreTool(object): raise CoreException("%s : is not a properly compressed tarfile." % (self.filepath,)) else: tar = tarfile.open(self.filepath, "r") - tar.extractall(self.dst) - for root, dirs, files in self.util.directoryList(dst): + # python 2.4 doesn't have extractall method + for tarinfo in tar: + tar.extract(tarfinfo.name, self.dst) + #tar.extractall(self.dst) + for root, dirs, files in self.util.directoryList(self.dst): for file in files: if self.isCorefile(file): return os.path.join(root,file) @@ -245,8 +249,8 @@ class CoreTool(object): raise CoreException("Unable to retrieve timestamp from: %s" % (path,))
class Download(object): -""" borrowed from anaconda's urlinstall method -""" + """ borrowed from anaconda's urlinstall method + """ def __init__(self, url, dst): self.url = url self.dst = dst @@ -255,14 +259,14 @@ class Download(object): self.file = os.path.basename(path) self.output = os.path.join(self.dst, self.file)
- def status(self, cur_bytes, tot_bytes): - sys.stdout.write("Downloaded %s of %s" % (cur_bytes, tot_bytes) + "\r") + def status(self, cur_percent): + sys.stdout.write("Downloading %3d%%" % (cur_percent) + "\r") sys.stdout.flush()
def get(self): try: url = grabber.urlopen(self.url) - except: grabber.URLGrabError, e: + except grabber.URLGrabError, e: raise IOError (e.errno, e.strerror)
# check size @@ -280,9 +284,9 @@ class Download(object): tot = len(buf) while len(buf) > 0: if filesize is not None: - self.status((100*tot)/filesize, filesize) + self.status((100*tot)/filesize) else: - self.status(tot/1024, filesize) + self.status(tot/1024) f.write(buf) buf = url.read(65535) tot += len(buf) diff --git a/version b/version index d5fc183..dd9b839 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.13 70 +0.13 71