def setUp(self): self.config = get_config_for_testing() self.fw_one = create_test_firmware(device_name='dev_1', all_files_included_set=True) self.fw_one.processed_analysis['file_hashes'] = {'ssdeep': get_ssdeep(self.fw_one.binary)} self.fw_two = create_test_firmware(device_name='dev_2', bin_path='container/test.7z', all_files_included_set=True) self.fw_two.processed_analysis['file_hashes'] = {'ssdeep': get_ssdeep(self.fw_two.binary)} self.compare_system = Compare(db_interface=MockDbInterface(), config=self.config)
def init_compare(hotspot_one, hotspot_two): """ Initialize comparison of hotspots """ path_for_one = "static/maps/" + hotspot_one + "/" + get_saved_csv( hotspot_one)[0] path_for_two = "static/maps/" + hotspot_two + "/" + get_saved_csv( hotspot_two)[0] csv_one = pandas.read_csv(path_for_one, usecols=[ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ], encoding="utf-8").values csv_two = pandas.read_csv(path_for_two, usecols=[ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ], encoding="utf-8").values compare = Compare(csv_one, csv_two) compare.calculate_overlap() compare.calculate_percentage() compare.calculate_jaccard() return { "data": compare.get_overlap(), "all_percentage": compare.get_percentage(), "jaccard": compare.get_jaccard(), # "pai": round(pai.pai_index(csv_one, csv_two), 3) # "z_max": use_max, # "z_min": use_min }
def __init__(self, config=None, db_interface=None, testing=False, callback=None): self.config = config self.db_interface = db_interface if db_interface else CompareDbInterface(config=config) self.stop_condition = Value('i', 1) self.in_queue = Queue() self.callback = callback self.compare_module = Compare(config=self.config, db_interface=self.db_interface) self.worker = ExceptionSafeProcess(target=self._compare_scheduler_main) if not testing: self.start()