Example #1
0
 def test_connect_disconnect(self):
     sync = Sync(self.prefs)
     self.assertTrue(sync.xmlrpc_connect())
     self.assertFalse(sync._Sync__server is None)
     self.assertTrue(sync._Sync__connected)
     sync.xmlrpc_disconnect()
     self.assertTrue(sync._Sync__server is None)
     self.assertFalse(sync._Sync__connected)
Example #2
0
 def test_connect_disconnect(self):
     sync = Sync(self.prefs)
     self.assertTrue(sync.xmlrpc_connect())
     self.assertFalse(sync._Sync__server is None)
     self.assertTrue(sync._Sync__connected)
     sync.xmlrpc_disconnect()
     self.assertTrue(sync._Sync__server is None)
     self.assertFalse(sync._Sync__connected)
Example #3
0
        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()
            
Example #4
0
        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()