def test_send_hosts(self): sync = Sync(self.prefs) self.assertEqual(sync.receive_new_hosts(), self.test_hosts) filename = ospj(self.work_dir, SYNC_RECEIVED_HOSTS) with open(filename) as f: hosts = [line.strip().split(':')[0] for line in f] self.assertEqual(self.test_hosts, hosts)
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() die("You have provided the --sync flag however your configuration file has SYNC_UPLOAD and SYNC_DOWNLOAD set to false.") try: sync = Sync(prefs) if sync_upload: timestamp = sync.send_new_hosts() if sync_download: new_hosts = sync.receive_new_hosts() if new_hosts: info("received new hosts: %s", str(new_hosts)) sync.get_denied_hosts() sync.update_hosts_deny(new_hosts) sync.xmlrpc_disconnect() except Exception, e: lock_file.remove() die("Error synchronizing data", e) # remove lock file on exit lock_file.remove()