282829293030SUBJECT = "Regression test results on %s using revision %s" % (TIME , REVISION )
31- CONTENT = ""
32- TEST_COUNTS = []
33- ATTACHMENTS = {}
3431
3532def prepare_email (content ):
3633 msg = MIMEMultipart ()
@@ -53,6 +50,10 @@ def send_email(msg):
5350 print "Failure to send email: %s" % str (e )
5451
5552def main ():
53+ content = ""
54+ test_counts = []
55+ attachments = {}
56+
5657 command_line = "cd %s && python sqlmap.py --live-test" % SQLMAP_HOME
5758 proc = subprocess .Popen (command_line , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
5859
@@ -74,13 +75,13 @@ def main():
7475 traceback = False if failed_test [5 ] == "False" else bool (failed_test [5 ])
7576 detected = False if failed_test [6 ] else True
7677
77- TEST_COUNTS .append (test_count )
78+ test_counts .append (test_count )
7879
7980 console_output_fd = codecs .open (os .path .join (output_folder , "console_output" ), "rb" , "utf8" )
8081 console_output = console_output_fd .read ()
8182 console_output_fd .close ()
8283
83- ATTACHMENTS [test_count ] = str (console_output )
84+ attachments [test_count ] = str (console_output )
8485
8586 log_fd = codecs .open (os .path .join (output_folder , "debiandev" , "log" ), "rb" , "utf8" )
8687 log = log_fd .read ()
@@ -91,28 +92,28 @@ def main():
9192 traceback = traceback_fd .read ()
9293 traceback_fd .close ()
9394
94- CONTENT += "Failed test case '%s'" % title
95+ content += "Failed test case '%s'" % title
9596
9697 if parse :
97- CONTENT += " at parsing: %s:\n \n " % parse
98- CONTENT += "### Log file:\n \n "
99- CONTENT += "%s\n " % log
98+ content += " at parsing: %s:\n \n " % parse
99+ content += "### Log file:\n \n "
100+ content += "%s\n " % log
100101 elif not detected :
101- CONTENT += " - SQL injection not detected\n \n "
102+ content += " - SQL injection not detected\n \n "
102103
103104 if traceback :
104- CONTENT += "### Traceback:\n \n "
105- CONTENT += "%s\n " % str (traceback )
105+ content += "### Traceback:\n \n "
106+ content += "%s\n " % str (traceback )
106107
107- CONTENT += "#######################################################################\n \n "
108+ content += "#######################################################################\n \n "
108109
109- if CONTENT :
110- SUBJECT += " (%s)" % ", " .join ("#%d" % count for count in TEST_COUNTS )
111- CONTENT += "\n \n Regression test finished at %s" % time .strftime ("%H:%M:%S %d-%m-%Y" , time .gmtime ())
110+ if content :
111+ SUBJECT += " (%s)" % ", " .join ("#%d" % count for count in test_counts )
112+ content += "\n \n Regression test finished at %s" % time .strftime ("%H:%M:%S %d-%m-%Y" , time .gmtime ())
112113
113- msg = prepare_email (CONTENT )
114+ msg = prepare_email (content )
114115
115- for test_count , attachment in ATTACHMENTS .items ():
116+ for test_count , attachment in attachments .items ():
116117 attachment = MIMEText (attachment )
117118 attachment .add_header ("Content-Disposition" , "attachment" , filename = "test_case_%d_console_output.txt" % test_count )
118119 msg .attach (attachment )
0 commit comments