def commit(self): if not self._lock.got_lock: raise obnamlib.RepositoryClientListNotLocked() tracing.trace('client list: %r', self._data._obj) for client_name in self._added_clients: self._hooks.call('repository-add-client', self, client_name) self._data.save() self._added_clients = [] self._lock.unchecked_unlock()
def remove_client(self, client_name): if not self._lock.got_lock: raise obnamlib.RepositoryClientListNotLocked() self._require_client_exists(client_name) clients = self._data.get('clients', {}) del clients[client_name] self._data['clients'] = clients if client_name in self._added_clients: self._added_clients.remove(client_name)
def add_client(self, client_name): if not self._lock.got_lock: raise obnamlib.RepositoryClientListNotLocked() self._require_client_does_not_exist(client_name) clients = self._data.get('clients', {}) clients[client_name] = { 'encryption-key': None, } self._data['clients'] = clients self._added_clients.append(client_name)
def rename_client(self, old_client_name, new_client_name): if not self._lock.got_lock: raise obnamlib.RepositoryClientListNotLocked() self._require_client_exists(old_client_name) self._require_client_does_not_exist(new_client_name) clients = self._data.get('clients', {}) clients[new_client_name] = clients[old_client_name] del clients[old_client_name] self._data['clients'] = clients if old_client_name in self._added_clients: # pragma: no cover self._added_clients.remove(old_client_name) self._added_clients.append(new_client_name)
def _require_client_list_lock(self): if not self.got_client_list_lock(): raise obnamlib.RepositoryClientListNotLocked()
def _raw_unlock_client_list(self): if not self.got_client_list_lock(): raise obnamlib.RepositoryClientListNotLocked() self._lockmgr.unlock(['.']) self._setup_client_list()
def _require_lock(self): if not self.data.locked: raise obnamlib.RepositoryClientListNotLocked()
def commit(self): if not self.data.locked: raise obnamlib.RepositoryClientListNotLocked() self.data.commit()
def unlock(self): if not self.data.locked: raise obnamlib.RepositoryClientListNotLocked() self.data.unlock()
def unlock(self): if not self._lock.got_lock: raise obnamlib.RepositoryClientListNotLocked() self._data.clear() self._lock.unchecked_unlock()