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()
def test_send_hosts(self): sync = Sync(self.prefs) self.assertFalse(sync._Sync__hosts_added) self.assertTrue(sync.send_new_hosts()) self.assertEqual(sync._Sync__hosts_added, self.test_hosts)