def test_delete_file(self): file_path = os.path.join(self.tmp_dir.name, "test_folder", "test_file") write_binary_to_file(b'this is a test', file_path) self.assertTrue(os.path.exists(file_path), "file not created") delete_file(file_path) self.assertFalse(os.path.exists(file_path)) # Test delete none existing file delete_file(file_path)
else: logger.setLevel(logging.INFO) console_logger = logging.StreamHandler() console_logger.setFormatter(log_format) logger.addHandler(console_logger) def _write_password_file(password_set, file_path): content = '\n'.join(list(password_set)).encode('utf-8') write_binary_to_file(content, file_path) if __name__ == '__main__': args = _setup_argparser() _setup_logging(args) logging.info('Update Password List...') logging.debug('remove old password file: {}'.format(args.output_file)) delete_file(args.output_file) logging.debug('read password files in {}'.format(args.password_lists_directory)) passwords = get_merged_password_set(args.password_lists_directory) logging.info('{} unique passwords found'.format(len(passwords))) logging.debug('writing passwords to file {}'.format(args.output_file)) _write_password_file(passwords, args.output_file) sys.exit()
def _remove_ini_files(tmp_dir): for file_name in get_files_in_dir(tmp_dir): if file_name.endswith('.ini'): delete_file(file_name)
def delete_file(self, uid): local_file_path = self.generate_path_from_uid(uid) delete_file(local_file_path)
def delete_file(self, file_object): local_file_path = self.generate_path(file_object) delete_file(local_file_path)