summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsuspicious20
1 files changed, 15 insertions, 5 deletions
diff --git a/suspicious b/suspicious
index fe09204..dedf43f 100755
--- a/suspicious
+++ b/suspicious
@@ -302,17 +302,27 @@ for file in filelist:
continue
opened +=1
now = datetime.datetime.now()
- estimate = (((now - start) / (opened + skipped)) * len(filelist))
if options.display_progress:
- if len(file)> 50:
+ frac_done = (opened + skipped)*1.0/len(filelist)
+ est = ((now - start) / (opened + skipped)) * len(filelist)
+ est_hr, est_rem = divmod(est.total_seconds(), 3600)
+ est_min, est_sec = divmod(est_rem, 60)
+ if len(file)> 52:
prog_file = file.split('/')[0] + "/.../" + file.split('/')[-1]
+ if len(prog_file) > 52:
+ prog_file = prog_file[0:52]
else:
prog_file = file
- print('\r' + " " * len(progresstext) + '\r', end='', file=sys.stderr)
- progresstext = str(((opened + skipped)*1.0/len(filelist))*100)[:5] + '% '+ " time left:" + str(estimate).split('.')[0] + ' ' + prog_file + '\r'
+ progresstext = \
+ "{:6.1%} time left: {:02.0f}:{:02.0f}:{:02.0f} {:52s}\r" \
+ .format(frac_done, est_hr, est_min, est_sec, prog_file)
print(progresstext, end='', file=sys.stderr)
sys.stdout.flush()
- filecontents = f.read()
+ try:
+ filecontents = f.read()
+ except UnicodeDecodeError:
+ print("possible binary: " + file)
+ continue
datasize += len(filecontents)
filenamescore = scoretext(wordlist, file, options.maxwholewordlength)
filecontentsscore = scoretext(wordlist, filecontents, options.maxwholewordlength)