From 93e4bd5c0f2e7b411a73b72db70bec10bab3ad6b Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Mon, 8 Oct 2018 21:47:11 -0600 Subject: [PATCH] Fix cleanup_d7ii() --- .bin/Scripts/functions/cleanup.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.bin/Scripts/functions/cleanup.py b/.bin/Scripts/functions/cleanup.py index 92a047a6..67675cbb 100644 --- a/.bin/Scripts/functions/cleanup.py +++ b/.bin/Scripts/functions/cleanup.py @@ -125,27 +125,29 @@ def cleanup_d7ii(): prefix=KIT_NAME_SHORT, date=d7_date, **global_vars['Env']) + os.makedirs(r'{}\d7II'.format(log_dest), exist_ok=True) + os.makedirs(r'{}\Tools'.format(log_dest), exist_ok=True) # Malware Logs if os.path.exists(d7_mlogs): m_report = 'MalwareScan_Report.txt' for m_entry in os.scandir(d7_mlogs): - dest_path = r'{}\{}\{}'.format( - log_dest, - 'd7II' if m_entry.name == m_report else 'Tools', - m_entry.name) + if m_entry.name == m_report: + dest_path = r'{}\d7II\{}'.format(log_dest, m_entry.name) + else: + dest_path = r'{}\Tools\{}'.format(log_dest, m_entry.name) dest_path = non_clobber_rename(dest_path) - shutil.move(entry.path, dest_path) + shutil.move(m_entry.path, dest_path) # Other items for o_entry in os.scandir(entry.path): dest_path = r'{log_dest}\d7II\{name}'.format( log_dest=log_dest, - name=m_entry.name) + name=o_entry.name) dest_path = non_clobber_rename(dest_path) # Just remove empty folders - if o_entry.isdir(): + if o_entry.is_dir(): try: os.rmdir(o_entry.path) except OSError: @@ -154,7 +156,7 @@ def cleanup_d7ii(): continue # Move item - shutil.move(entry.path, dest_path) + shutil.move(o_entry.path, dest_path) # Remove folder delete_empty_folders(entry.path)