示例#1
1
def sync(devices=[]):
    '''
    Run continuous synchronization between CouchDB instances.
    '''
    if len(devices) == 0:
        devices = local_config.get_default_devices()

    for name in devices:
        (url, path) = local_config.get_config(name)
        (device_id, device_password) = local_config.get_device_config(name)
        (db_login, db_password) = local_config.get_db_credentials(name)

        print 'Start continuous replication from Cozy to device.'
        replication.replicate(name, url, name, device_password, device_id,
                              db_login, db_password, to_local=True)
        print 'Start continuous replication from device to Cozy.'
        replication.replicate(name, url, name, device_password, device_id,
                              db_login, db_password)

        print 'Continuous replications started.'
        print 'Running daemon for binary synchronization...'
        try:
            context = local_config.get_daemon_context(name, 'sync')
            with context:
                replication.BinaryReplication(name)
        except KeyboardInterrupt:
            print ' Binary Synchronization interrupted.'
示例#2
0
def start_sync():
    print 'Continuous replications started.'
    print 'Running daemon for binary synchronization...'
    name = 'sync'
    context = local_config.get_daemon_context(name, 'sync')
    with context:
        replication.BinaryReplication(name)
示例#3
0
def sync_daemon(name):
    '''
    Run the binary synchronization in a daemon.
    '''
    context = local_config.get_daemon_context(name, 'sync')
    with context:
        sync(name)
示例#4
0
def sync(name):
    '''
    Run continuous synchronization between CouchDB instances.
    '''
    (url, path) = local_config.get_config(name)
    (device_id, device_password) = local_config.get_device_config(name)
    (db_login, db_password) = local_config.get_db_credentials(name)

    replication.replicate(name, url, name, device_password, device_id,
                          db_login, db_password, to_local=True)
    replication.replicate(name, url, name, device_password, device_id,
                          db_login, db_password)

    print 'Continuous replications started.'
    print 'Running daemon for binary synchronization...'
    try:
        context = local_config.get_daemon_context(name, 'sync')
        with context:
            replication.BinaryReplication(name)
    except KeyboardInterrupt:
        print ' Binary Synchronization interrupted.'