MOD: code cleanup to be more consistant with print statements and exception handing when calling the API
This commit is contained in:
parent
2e12a2cce1
commit
2c3ef39e24
18
dbfp.py
18
dbfp.py
|
@ -27,11 +27,10 @@ def compareFingerprint(file_in, file_json):
|
|||
|
||||
#
|
||||
def createFingerprint(file_in, verbose, app_name, app_ver, notes):
|
||||
print "Reading database file: {}".format(file_in)
|
||||
db = FingerprintDB()
|
||||
retVal = db.scanDBFile(file_in)
|
||||
|
||||
print "GOT HERE BITCHES: file_in=={}, retVal=={}".format(file_in, str(retVal))
|
||||
|
||||
if (retVal > 0):
|
||||
if verbose:
|
||||
db.debugFingerprint()
|
||||
|
@ -41,7 +40,8 @@ def createFingerprint(file_in, verbose, app_name, app_ver, notes):
|
|||
db.setAppVer(app_ver)
|
||||
if notes:
|
||||
db.setNotes(notes)
|
||||
db.writeFingerprint()
|
||||
filename = db.writeFingerprint()
|
||||
print "Fingerprint generated: {}".format(filename)
|
||||
else:
|
||||
print db.getErrorString(retVal)
|
||||
|
||||
|
@ -81,16 +81,16 @@ def androidPull():
|
|||
return
|
||||
|
||||
if (not mkdir(BASE_DIR)):
|
||||
logging.error("ERROR creating directory: {}".format(BASE_DIR))
|
||||
print "ERROR creating directory: {}".format(BASE_DIR)
|
||||
return
|
||||
if (not mkdir(FP_BASE_DIR)):
|
||||
logging.error("ERROR creating directory: {}".format(FP_BASE_DIR))
|
||||
print "ERROR creating directory: {}".format(FP_BASE_DIR)
|
||||
return
|
||||
|
||||
dir_names = ap.getAppsDir()
|
||||
for dir_name in dir_names:
|
||||
fq_dir = BASE_DIR + os.path.sep + dir_name
|
||||
ap.pullApp(BASE_DIR, dir_name)
|
||||
fq_dir = BASE_DIR + os.path.sep + dir_name
|
||||
__createFingerprint(fq_dir, FP_BASE_DIR, dir_name)
|
||||
|
||||
#
|
||||
|
@ -99,12 +99,12 @@ def androidData(data_dir):
|
|||
try:
|
||||
dirs = os.listdir(data_dir)
|
||||
except Exception, ex:
|
||||
print "ERROR opening Android data directory [{}]\n{}".format(data_dir, ex)
|
||||
print "ERROR opening Android Data Directory (-dd): {}\n{}".format(data_dir, ex)
|
||||
return
|
||||
|
||||
out_dir = FP_BASE_DIR + "_" + ToolBox.getTimestampStr()
|
||||
if (not mkdir(out_dir)):
|
||||
logging.error("ERROR creating directory: {}".format(FP_BASE_DIR))
|
||||
print "ERROR creating directory: {}".format(FP_BASE_DIR)
|
||||
return
|
||||
|
||||
for ddir in dirs:
|
||||
|
@ -143,7 +143,7 @@ def mkdir(fdir):
|
|||
check_call(["mkdir", fdir])
|
||||
retval = True
|
||||
except:
|
||||
logging.error('ERROR: problem creating directory "{}"'.format(fdir))
|
||||
print 'ERROR: problem creating directory "{}"'.format(fdir)
|
||||
return retval
|
||||
|
||||
#
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
|
||||
[[ TODO ]]
|
||||
|
||||
[ Regression Testing ]
|
||||
android pull, data dir, comparison
|
||||
|
||||
[ Pull Apps from Internet ]
|
||||
http://www.aptoide.com/webservices/docs/2/getApkInfo
|
||||
|
||||
[ Static Code Analysis ]
|
||||
AFL (python port)
|
||||
http://lcamtuf.coredump.cx/afl/
|
||||
https://bitbucket.org/jwilk/python-afl/src/af96425344b992ba6b8ea2c446e8eeea5dc43ccd/doc/?at=default
|
||||
|
||||
[ Android Pull ]
|
||||
-test android pull (regression testing)
|
||||
-try VM android pull?
|
||||
|
@ -61,3 +72,26 @@
|
|||
|
||||
[[ Errors ]]
|
||||
|
||||
file is encrypted or is not a database
|
||||
WARN: field definition not recognized: "[version] INTEGER"
|
||||
WARN: field definition not recognized: "[corpus_name] STRING PRIMARY KEY"
|
||||
WARN: field definition not recognized: "[incarnation] STRING"
|
||||
WARN: field definition not recognized: "[seqno_table_complete] INTEGER"
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
file is encrypted or is not a database
|
||||
|
||||
|
|
|
@ -89,7 +89,6 @@ class FingerprintDB:
|
|||
return
|
||||
|
||||
try:
|
||||
print "FILE=={}".format(self.filein)
|
||||
filename = ToolBox.getTimestampFilename(self.filein)
|
||||
fh = open(filename, "w")
|
||||
try:
|
||||
|
@ -100,6 +99,8 @@ class FingerprintDB:
|
|||
logging.error(ex)
|
||||
raise FingerprintWrite("Problem writing the fingerprint to a file, file=={}".format(filename))
|
||||
|
||||
return filename
|
||||
|
||||
#
|
||||
def writeFingerprintFile(self, filename):
|
||||
if (not self.init):
|
||||
|
|
Loading…
Reference in New Issue