cas | 27 ++++++++++++++-------------
cas-admin | 5 +----
lib/cas/core.py | 15 +++++++++------
3 files changed, 24 insertions(+), 23 deletions(-)
New commits:
commit 48b15e231ca48d1f43701c967c8f94071892b0bf
Author: Adam Stokes <adam(a)conans.battleaxe>
Date: Thu Dec 4 07:38:12 2008 -0500
more work to extracting of cores and processing
diff --git a/cas b/cas
index bce1e3e..076c603 100755
--- a/cas
+++ b/cas
@@ -54,10 +54,10 @@ class CoreHandler(object):
os.path.join(self.dst, self.filename))
return os.path.realpath(self.filename)
try:
- self.tool.extractCore(self.filename, self.dst)
+ corepath = self.tool.extractCore(self.filename, self.dst)
return os.path.realpath(corepath)
- except CoreException, err:
- dprint(err, DPRINT)
+ except:
+ dprint("Unable to extract corefile", DPRINT)
sys.exit(1)
class TimestampHandler(object):
@@ -78,7 +78,7 @@ class TimestampHandler(object):
debugKernel, timestamp = coreObj
if timestamp and coreTimestamp in timestamp:
return (k, debugKernel)
- dprint("Unable to match (%s,%s) with debugKernel" % (self.corefile,
coreTimestamp), DPRINT)
+ dprint("Unable to match (%s,%s) with debugKernel\n" % (self.corefile,
coreTimestamp), DPRINT)
sys.exit(1)
class CasApplication(object):
@@ -109,7 +109,7 @@ class CasApplication(object):
if not os.path.isdir(self.storagePath):
os.makedirs(self.storagePath)
corefile = CoreHandler(self.filename, self.storagePath).run()
- dprint(corefile, DPRINT)
+ dprint(corefile + "\n", DPRINT)
debuginfo, debugKernel = TimestampHandler(corefile).run()
filterString = "*/%s" % (debugKernel,)
self.rpmTool.extract(debuginfo, self.storagePath,
@@ -132,21 +132,22 @@ class CasApplication(object):
# TODO: Randomize server selection
casProcessMachine = serverList[debugKernelArch][0]
cmd = "cd %s; %s" % (self.storagePath,
-
os.path.join(self.storagePath,"crash")
+
os.path.join(self.storagePath,"crash"))
client = fc.Overlord(casProcessMachine)
client_dict = client.command.run(cmd)
- (sts, out, err) = client_dict[client_dict.keys()[0]]
+ # Only necessary for debugging why running of crash failed.
+ # (sts, out, err) = client_dict[client_dict.keys()[0]]
else:
- print("No servers available for arch, please run cas-admin -h \
- for more information")
+ print("No servers available for arch, please run cas-admin -h
" \
+ "for more information")
print("Continueing without processing core.")
else:
- print("No servers database found, please run cas-admin -h for \
- more information")
+ print("No servers database found, please run cas-admin -h for "
\
+ "more information")
sys.exit(1)
except ImportError:
- print("You need to install func (
http://fedorahosted.org/func if you \
- wish to have the data processed automatically.")
+ print("You need to install func (
http://fedorahosted.org/func if you
"\
+ "wish to have the data processed automatically.")
# TODO: Possibly handle this exception more gracefully?
print("Job on %s complete and located in %s." %
(self.filename,self.storagePath))
return
diff --git a/cas-admin b/cas-admin
index 6e6f502..6dff211 100755
--- a/cas-admin
+++ b/cas-admin
@@ -127,9 +127,6 @@ class CasAdminApplication(object):
parser.add_option("-s","--server",
dest="server_init",
help="Build SERVER DB",
action="store_true", default=False)
(self.opts, args) = parser.parse_args()
- if len(args) > 2:
- parser.error("Please only define one administrator action at a
time.")
- sys.exit(1)
self.buildDB = self.opts.buildDB
self.server_init = self.opts.server_init
@@ -147,7 +144,7 @@ class CasAdminApplication(object):
if self.buildDB:
print("::: Starting CAS DB instance. :::")
dbHandler = CasDatabaseHandler().run()
- elif self.server_init is not None:
+ elif self.server_init:
print("::: Building CAS Server DB instance. :::")
serverHandler = CasServerHandler().run()
else:
diff --git a/lib/cas/core.py b/lib/cas/core.py
index e6fcdef..c1d9bc2 100644
--- a/lib/cas/core.py
+++ b/lib/cas/core.py
@@ -10,8 +10,10 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <
http://www.gnu.org/licenses/>.
+import os
from cas.util import UtilBase
+from subprocess import Popen, PIPE, call
class CoreException(Exception):
pass
@@ -27,7 +29,6 @@ class CoreBase(object):
"gz" : ["gunzip", "-q"],
"tbz" : ["tar", "xvjf"],
"bz2" : ["bunzip2", "-q"],
- "Z" : ["uncompress"],
"zip" : ["unzip", "-f"]}
def string(offset, match):
return data[offset:offset + len(match)] == match
@@ -51,7 +52,7 @@ class CoreBase(object):
return False
def extractCore(self, filepath, dst):
- """ utility to extract tarfile and pull out core
+ """ utility to extract archive and pull out core
"""
self.dst = dst
self.filepath = filepath
@@ -62,10 +63,12 @@ class CoreBase(object):
raise CoreException("Can not determine compression format.")
else:
os.chdir(self.dst)
- format.append(os.path.basename(self.filepath))
- ret = call(format)
- if ret:
- raise CoreException("Unable to extract file based on compression
format.")
+ format.append(self.filepath)
+ p = Popen(format, stdout=PIPE, stderr=PIPE)
+ err = p.stderr.read()
+ out = p.stdout.read()
+ if err:
+ raise CoreException("Unable to extract file based on compression
format.: %s" % (err,))
for root, dirs, files in self.util.directoryList(self.dst):
for file in files:
if self.isCorefile(file):