(user, synclist, stopsync)
Updates the current Device Sync status

    Synchronisation between devices can be set up and stopped.  Devices are
    identified by their UIDs. Unknown UIDs cause errors, no new devices are
    created.
Updates the current Device Sync status
Updates the current Device Sync status
def update_sync_status(user, synclist, stopsync):
    """Updates the current Device Sync status

    Synchronisation between devices can be set up and stopped.  Devices are
    identified by their UIDs. Unknown UIDs cause errors, no new devices are
    created."""

    for devlist in synclist:

        if len(devlist) <= 1:
            raise ValueError("at least two devices are needed to sync")

        # Setup all devices to sync with the first in the list
        uid = devlist[0]
        dev = user.client_set.get(uid=uid)

        for other_uid in devlist[1:]:
            other = user.client_set.get(uid=other_uid)
            dev.sync_with(other)

    for uid in stopsync:
        dev = user.client_set.get(uid=uid)
        try:
            dev.stop_sync()
        except ValueError:
            # if all devices of a sync-group are un-synced,
            # the last one will raise a ValueError, because it is no longer
            # being synced -- we just ignore it
            pass

    user.save()

    sync_user.delay(user)
def update_sync_status ( user , synclist , stopsync ) : for devlist in synclist : if len ( devlist ) <= 1 : raise ValueError ( "at least two devices are needed to sync" ) # Setup all devices to sync with the first in the list uid = devlist [ 0 ] dev = user . client_set . get ( uid = uid ) for other_uid in devlist [ 1 : ] : other = user . client_set . get ( uid = other_uid ) dev . sync_with ( other ) for uid in stopsync : dev = user . client_set . get ( uid = uid ) try : dev . stop_sync ( ) except ValueError : # if all devices of a sync-group are un-synced, # the last one will raise a ValueError, because it is no longer # being synced -- we just ignore it pass user . save ( ) sync_user . delay ( user )