From c61ee5e5eff482630437a49da8645cf50a39ddba Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Fri, 18 Jan 2013 15:34:14 +0000 Subject: [PATCH] more adjustments --- extra/shutils/regressiontest.py | 37 +++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/extra/shutils/regressiontest.py b/extra/shutils/regressiontest.py index 23302bd94..46ae72138 100644 --- a/extra/shutils/regressiontest.py +++ b/extra/shutils/regressiontest.py @@ -28,9 +28,6 @@ SMTP_TIMEOUT = 30 FROM = "regressiontest@sqlmap.org" TO = "dev@sqlmap.org" SUBJECT = "Regression test results on %s using revision %s" % (TIME, REVISION) -CONTENT = "" -TEST_COUNTS = [] -ATTACHMENTS = {} def prepare_email(content): msg = MIMEMultipart() @@ -53,6 +50,10 @@ def send_email(msg): print "Failure to send email: %s" % str(e) def main(): + content = "" + test_counts = [] + attachments = {} + command_line = "cd %s && python sqlmap.py --live-test" % SQLMAP_HOME proc = subprocess.Popen(command_line, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -74,13 +75,13 @@ def main(): traceback = False if failed_test[5] == "False" else bool(failed_test[5]) detected = False if failed_test[6] else True - TEST_COUNTS.append(test_count) + test_counts.append(test_count) console_output_fd = codecs.open(os.path.join(output_folder, "console_output"), "rb", "utf8") console_output = console_output_fd.read() console_output_fd.close() - ATTACHMENTS[test_count] = str(console_output) + attachments[test_count] = str(console_output) log_fd = codecs.open(os.path.join(output_folder, "debiandev", "log"), "rb", "utf8") log = log_fd.read() @@ -91,28 +92,28 @@ def main(): traceback = traceback_fd.read() traceback_fd.close() - CONTENT += "Failed test case '%s'" % title + content += "Failed test case '%s'" % title if parse: - CONTENT += " at parsing: %s:\n\n" % parse - CONTENT += "### Log file:\n\n" - CONTENT += "%s\n" % log + content += " at parsing: %s:\n\n" % parse + content += "### Log file:\n\n" + content += "%s\n" % log elif not detected: - CONTENT += " - SQL injection not detected\n\n" + content += " - SQL injection not detected\n\n" if traceback: - CONTENT += "### Traceback:\n\n" - CONTENT += "%s\n" % str(traceback) + content += "### Traceback:\n\n" + content += "%s\n" % str(traceback) - CONTENT += "#######################################################################\n\n" + content += "#######################################################################\n\n" - if CONTENT: - SUBJECT += " (%s)" % ", ".join("#%d" % count for count in TEST_COUNTS) - CONTENT += "\n\nRegression test finished at %s" % time.strftime("%H:%M:%S %d-%m-%Y", time.gmtime()) + if content: + SUBJECT += " (%s)" % ", ".join("#%d" % count for count in test_counts) + content += "\n\nRegression test finished at %s" % time.strftime("%H:%M:%S %d-%m-%Y", time.gmtime()) - msg = prepare_email(CONTENT) + msg = prepare_email(content) - for test_count, attachment in ATTACHMENTS.items(): + for test_count, attachment in attachments.items(): attachment = MIMEText(attachment) attachment.add_header("Content-Disposition", "attachment", filename="test_case_%d_console_output.txt" % test_count) msg.attach(attachment)