More robust analysis tool

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4187 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2010-09-01 20:24:04 +00:00
parent ca503e5801
commit 924e16f4f0
1 changed files with 9 additions and 1 deletions

View File

@ -29,6 +29,10 @@ def main():
parser.add_option("", "--max_days", dest="maxDays",
type='int', default=None,
help="if provided, only records generated within X days of today will be included")
parser.add_option("", "--D", dest="reallyDeleteInArchiveMode",
action='store_true', default=False,
help="if provided, we'll actually delete records when running in archive mode")
(OPTIONS, args) = parser.parse_args()
if len(args) == 0:
@ -39,6 +43,8 @@ def main():
# open up the output file
if OPTIONS.output != None:
if stage == "archive" and os.path.exists(OPTIONS.output):
raise "archive output file already exists, aborting!", OPTIONS.output
out = openFile(OPTIONS.output,'w')
else:
out = sys.stdout
@ -182,9 +188,11 @@ class Archive(RecordAsXML):
RecordAsXML.__init__(self, name, out)
def finalize(self, args):
RecordAsXML.finalize(self, args)
for arg in args:
print 'Deleting file: ', arg
os.remove(arg)
if OPTIONS.reallyDeleteInArchiveMode:
os.remove(arg)
addHandler('archive', Archive)