summaryrefslogtreecommitdiff
path: root/suspicious
diff options
context:
space:
mode:
authorDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2016-06-29 18:16:47 -0400
committerDaniel Gnoutcheff <gnoutchd@softwarefreedom.org>2016-06-29 18:16:47 -0400
commit49e9ddf62971fc0073fec428b7b75569e2860cbc (patch)
tree4b1a1534bd522a955bb0343281f27a020dfe4c94 /suspicious
parent4d4dbed2737a54ccabaa40f829c0c2a93fbe9750 (diff)
handle binary files, more progress line fixes
Diffstat (limited to 'suspicious')
-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)