cas | 17 ++++++-----------
cas-admin | 10 ++++------
2 files changed, 10 insertions(+), 17 deletions(-)
New commits:
commit 294cdaa0bef11650177a9aa4d8db965415f6e5b7
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Fri May 1 18:02:00 2009 -0400
- re-worked exit on exception
diff --git a/cas b/cas
index ca5e457..9dde862 100755
--- a/cas
+++ b/cas
@@ -76,8 +76,7 @@ class CoreHandler(object):
if not os.path.isfile(self.filename):
# not a url in this case so tests for local existence
# TODO: add support to check remote hosts
- self.casLog.debug("Unable to find file %s" % (self.filename,))
- sys.exit(1)
+ raise SystemExit(self.casLog.debug("Unable to find file %s" %
(self.filename,)))
if self.tool.isCorefile(self.filename):
# No need to proceed to extracting corefile since we assume
# this is already at the proper stage.
@@ -102,8 +101,7 @@ class CoreHandler(object):
self.filename = os.path.join(self.dst, coreBasename)
return self.filename
except CoreException, err:
- self.casLog.debug(err)
- sys.exit(1)
+ raise SystemExit(self.casLog.debug(err))
class TimestampHandler(object):
def __init__(self, corefile, logger, database):
@@ -119,15 +117,13 @@ class TimestampHandler(object):
try:
coreTimestamp = self.tool.timestamp(self.corefile)
except CoreException, err:
- self.casLog.debug(err)
- sys.exit(1)
+ raise SystemExit(self.casLog.debug(err))
# query timestamp table, return tuple debuginfoRPM, and path to
# debugKernel
timestamp_query = self.db.getTimestampDebug(coreTimestamp)
if timestamp_query:
return (timestamp_query)
- self.casLog.debug("Unable to match timestamp %s" % (coreTimestamp,))
- sys.exit(1)
+ raise SystemExit(self.casLog.debug("Unable to match timestamp %s" %
(coreTimestamp,)))
class CasApplication(object):
def __init__(self, args):
@@ -296,9 +292,8 @@ class CasApplication(object):
"suitable for processing, please run cas-admin -h
" \
"for more information")
else:
- self.casLog.info("No servers database found, please run
cas-admin -h for " \
- "more information")
- sys.exit(1)
+ raise SystemExit(self.casLog.info("No servers database found,
please run cas-admin -h for " \
+ "more information"))
except ImportError:
self.casLog.info("Current running machine is not suitable for
processing this core " \
"and
http://fedorahosted.org/func is not installed/configured
properly.")
diff --git a/cas-admin b/cas-admin
index 193427e..e04c125 100755
--- a/cas-admin
+++ b/cas-admin
@@ -111,7 +111,7 @@ class CasServerHandler(object):
import func.overlord.client as fc
parent_func = fc.Overlord("*")
minions = parent_func.minions
- # TODO: add only servers that respond, purge the rest
+ # DONE: add only servers that respond, purge the rest
for i in minions:
scheme, netloc, path, query, frag = urlparse.urlsplit(i)
hostname, port = netloc.split(":")
@@ -133,9 +133,8 @@ class CasServerHandler(object):
hostname_count = hostname_count + 1
self.casLog.info("Server database built with %d server(s) added." %
(hostname_count,))
except ImportError:
- self.casLog.debug("Please install func (
http://fedorahosted.org/func)
for " \
- "an automated machine arch population.\n")
- sys.exit(1)
+ raise SystemExit(self.casLog.debug("Please install func
(
http://fedorahosted.org/func) for " \
+ "an automated machine arch population.\n"))
return
class CasAdminApplication(object):
@@ -190,8 +189,7 @@ class CasAdminApplication(object):
self.casLog.info("Building CAS Server DB instance.")
serverHandler = CasServerHandler(self.casLog).run()
else:
- self.casLog.info("Missing options, please run with --help.")
- sys.exit(1)
+ raise SystemExit(self.casLog.info("Missing options, please run with
--help."))
if __name__=="__main__":
app = CasAdminApplication(sys.argv[1:])