-
Notifications
You must be signed in to change notification settings - Fork 139
/
Cleaner.py
24 lines (23 loc) · 953 Bytes
/
Cleaner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import logging, os
from Constants import PASSWORD_EXTENSION_FILE
def runCleaner (args):
'''
Clean traces and logs
'''
logging.info("Cleaning files generated by PasswordGuesser ...")
nbFileDeleted, nbFileToDelete = 0, 0
exts=[PASSWORD_EXTENSION_FILE]
pathOfMsat = os.path.dirname(os.path.abspath(__file__))
for root, dirs, files in os.walk(pathOfMsat):
for currentFile in files:
logging.debug("Processing file: {0}".format(currentFile))
for ext in exts:
if currentFile.lower().endswith(ext) :
rep = input("Do you want to delete this file (Y for yes): {0}/{1}? ".format(root, currentFile))
if rep.replace('\n','') == 'Y' :
os.remove(os.path.join(root, currentFile))
logging.info("Removing {0}/{1}".format(root, currentFile))
nbFileDeleted += 1
nbFileToDelete += 1
args['print'].goodNews("Finish: {0}/{1} file(s) deleted".format(nbFileDeleted, nbFileToDelete))
logging.info("Cleaning is finished")