def test_04_file_rotated(self): ft = FileTracker(self.WORK_DIR, self.LOG_FILE) self.write_new_file() self.assertIsNone(ft.update_first_line()) self.assertEqual(ft.get_offset(), 0) self.setup_denyhosts() new_offset = DenyHosts(self.LOG_FILE, self.prefs, self.lock_file).process_log(self.LOG_FILE, ft.get_offset()) self.assertIsNone(ft.save_offset(new_offset)) self.assertEqual(ft.get_offset(), new_offset) self.lock_file.remove()
purge_time = prefs.get('PURGE_DENY') if not purge_time: lock_file.remove() die("You have provided the --purge flag however you have not set PURGE_DENY in your configuration file.") else: try: p = Purge(prefs, purge_time) except Exception, e: lock_file.remove() die(str(e)) try: for f in logfiles: dh = DenyHosts(f, prefs, lock_file, ignore_offset, first_time, noemail, daemon) except SystemExit, e: pass except Exception, e: traceback.print_exc(file=sys.stdout) print "\nDenyHosts exited abnormally" if sync_mode and not daemon: if not prefs.get('SYNC_SERVER'): lock_file.remove() die("You have provided the --sync flag however your configuration file is missing a value for SYNC_SERVER.") sync_upload = is_true(prefs.get("SYNC_UPLOAD")) sync_download = is_true(prefs.get("SYNC_DOWNLOAD")) if not sync_upload and not sync_download: lock_file.remove()
purge_time = prefs.get('PURGE_DENY') if not purge_time: lock_file.remove() die("You have provided the --purge flag however you have not set PURGE_DENY in your configuration file.") else: try: p = Purge(prefs, purge_time) except Exception as e: lock_file.remove() die(str(e)) try: for f in logfiles: dh = DenyHosts(f, prefs, lock_file, ignore_offset, first_time, noemail, daemon, foreground) except KeyboardInterrupt: pass except SystemExit as e: pass except Exception as e: traceback.print_exc(file=sys.stdout) print("\nDenyHosts exited abnormally") if sync_mode and not (daemon or foreground): if not prefs.get('SYNC_SERVER'): lock_file.remove() die("You have provided the --sync flag however your configuration file is missing a value for SYNC_SERVER.") sync_upload = is_true(prefs.get("SYNC_UPLOAD")) sync_download = is_true(prefs.get("SYNC_DOWNLOAD"))
purge_time = prefs.get('PURGE_DENY') if not purge_time: lock_file.remove() die("You have provided the --purge flag however you have not set PURGE_DENY in your configuration file." ) else: try: p = Purge(prefs, purge_time) except Exception as e: lock_file.remove() die(str(e)) try: for f in logfiles: dh = DenyHosts(f, prefs, lock_file, ignore_offset, first_time, noemail, daemon, foreground) except KeyboardInterrupt: pass except SystemExit as e: pass except Exception as e: traceback.print_exc(file=sys.stdout) print("\nDenyHosts exited abnormally") if sync_mode and not (daemon or foreground): if not prefs.get('SYNC_SERVER'): lock_file.remove() die("You have provided the --sync flag however your configuration file is missing a value for SYNC_SERVER." ) sync_upload = is_true(prefs.get("SYNC_UPLOAD")) sync_download = is_true(prefs.get("SYNC_DOWNLOAD"))
def test_init(self): DenyHosts(self.logfile, self.prefs, self.lock_file)