From 924e16f4f005e59aa87f4c35fd75b310a5108e36 Mon Sep 17 00:00:00 2001 From: depristo Date: Wed, 1 Sep 2010 20:24:04 +0000 Subject: [PATCH] More robust analysis tool git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4187 348d0f76-0448-11de-a6fe-93d51630548a --- python/analyzeRunReports.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/python/analyzeRunReports.py b/python/analyzeRunReports.py index 234fb7335..14a380f48 100755 --- a/python/analyzeRunReports.py +++ b/python/analyzeRunReports.py @@ -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)