Skip to content

Commit df30103

Browse files
authored
Merge pull request #2 from cclauss/modernize-python2-code
Modernize Python 2 code to get ready for Python 3
2 parents 7fd767b + 07b1926 commit df30103

File tree

9 files changed

+849
-828
lines changed

9 files changed

+849
-828
lines changed

analyze.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
from __future__ import print_function
23
import datetime
34
import getopt
45
import getpass
@@ -9,6 +10,10 @@
910
import time
1011
import classes.settings
1112
from classes.dump import Dump
13+
try:
14+
reload # Python 2
15+
except NameError: # Python 3
16+
from importlib import reload
1217

1318
MAX = 999999999 # ridiculous high number to get all the occurrences of a function
1419

@@ -30,7 +35,7 @@ def dump_results(self, method, toplimit, extra):
3035
try:
3136
method_to_call = getattr(self, method)
3237
except:
33-
print "Error: method should be a valid local method name\n"
38+
print("Error: method should be a valid local method name\n")
3439
help()
3540
start_time = time.time()
3641
if method != "report":
@@ -42,13 +47,13 @@ def dump_results(self, method, toplimit, extra):
4247
try:
4348
method_to_call(self.settings['output_type'], toplimit, extra)
4449
except Exception as e:
45-
print "Error executing the method: %s" % e
50+
print("Error executing the method: %s" % e)
4651
return
4752
else:
4853
try:
4954
method_to_call(self.settings['output_type'], toplimit)
5055
except Exception as e:
51-
print "Error executing the method: %s" % e
56+
print("Error executing the method: %s" % e)
5257
return
5358

5459
self.dump.post_general(self.settings['output_type'])
@@ -370,7 +375,7 @@ def analyze_return_code_differences(self, output, toplimit):
370375
def analyze_username_disclosure(self, output, toplimit, username=None):
371376
"""Find when a specific username is disclosed in the stdout or in the stderr"""
372377
if username is None:
373-
print "Error: extra parameter username has not been defined"
378+
print("Error: extra parameter username has not been defined")
374379
help()
375380
title = "Analyze Username Disclosure: " + username + " - analyze_username_disclosure"
376381
columns = ["Testcase", "Software", "Type", "OS", "Stdout", "Stderr"]
@@ -802,13 +807,13 @@ def analyze_elapsed(self, output, toplimit):
802807
def help(err=""):
803808
"""Print a help screen and exit"""
804809
if err:
805-
print "Error: %s\n" % err
806-
print "Syntax: "
807-
print os.path.basename(__file__) + " -d db.sqlite Choose the database"
808-
print "\t [-m methodName] Method: report (default), analyze_stdout, analyze_specific_return_code, etc"
809-
print "\t [-e extra_parameter] Extra parameter used when specifying a for certain methodName (ie, analyze_username_disclosure)"
810-
print "\t [-o html] Output: html (default), txt or csv."
811-
print "\t [-l 20] Top limit results (default: 20)"
810+
print("Error: %s\n" % err)
811+
print("Syntax: ")
812+
print(os.path.basename(__file__) + " -d db.sqlite Choose the database")
813+
print("\t [-m methodName] Method: report (default), analyze_stdout, analyze_specific_return_code, etc")
814+
print("\t [-e extra_parameter] Extra parameter used when specifying a for certain methodName (ie, analyze_username_disclosure)")
815+
print("\t [-o html] Output: html (default), txt or csv.")
816+
print("\t [-l 20] Top limit results (default: 20)")
812817
sys.exit()
813818

814819
def main():

classes/dbsqlite.py

Lines changed: 163 additions & 161 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)