From e369ef2933d63fec991121f5f7b6769b09d9660e Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Sun, 2 Oct 2022 14:18:59 -0400 Subject: [PATCH] BB: Remove disused MonkeyLog --- .../blackbox/log_handlers/monkey_log.py | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 envs/monkey_zoo/blackbox/log_handlers/monkey_log.py diff --git a/envs/monkey_zoo/blackbox/log_handlers/monkey_log.py b/envs/monkey_zoo/blackbox/log_handlers/monkey_log.py deleted file mode 100644 index 1e7e0098b..000000000 --- a/envs/monkey_zoo/blackbox/log_handlers/monkey_log.py +++ /dev/null @@ -1,39 +0,0 @@ -import logging -import os - -from bson import ObjectId - -LOGGER = logging.getLogger(__name__) - - -class MonkeyLog(object): - def __init__(self, monkey, log_dir_path): - self.monkey = monkey - self.log_dir_path = log_dir_path - - def download_log(self, island_client): - log = island_client.find_log_in_db({"monkey_id": ObjectId(self.monkey["_id"])}) - if not log: - LOGGER.error("Log for monkey {} not found".format(self.monkey["ip_addresses"][0])) - return False - else: - self.write_log_to_file(log) - return True - - def write_log_to_file(self, log): - with open(self.get_log_path_for_monkey(self.monkey), "w") as log_file: - log_file.write(MonkeyLog.parse_log(log)) - - # TODO: What's this for? Can we remove it? - @staticmethod - def parse_log(log): - log = log.strip('"') - log = log.replace("\\n", "\n ") - return log - - @staticmethod - def get_filename_for_monkey_log(monkey): - return "{}.txt".format(monkey["ip_addresses"][0]) - - def get_log_path_for_monkey(self, monkey): - return os.path.join(self.log_dir_path, MonkeyLog.get_filename_for_monkey_log(monkey))