def register_device_remotely(name, password): ''' Register device to target Cozy ''' (url, path) = local_config.get_config(name) if url[-1:] == '/': url = url[:-(len(name)+1)] try: (device_id, device_password) = remote.register_device(name, url, path, password) local_config.set_device_config(name, device_id, device_password) except remote.WrongCozyURL, e: local_config.remove_config(name) raise ProcessedException(e)
def remove_device(device): ''' Remove device from local and remote configuration by: * Unmounting device folder. * Removing device on corresponding remote cozy. * Removing device from configuration file. * Destroying corresponding DB. ''' (url, path) = local_config.get_config(device) couchmount.unmount(path) remove_device_remotely(device) # Remove database dbutils.remove_db(device) dbutils.remove_db_user(device) local_config.remove_config(device) print 'Configuration %s successfully removed.' % device