def _save_userdata(self, metadata): """ Save the given noticeboard metadata to disk. @param metadata: repository user metadata to store @type metadata: dict @raise KeyError: if given repository identifier is not available @raise RepositoryError: if given repository directory is not available """ avail_data = self._settings['repositories']['available'] nb_path = avail_data[self._repository_id]['local_notice_board'] nb_dir = os.path.dirname(nb_path) if not const_dir_writable(nb_dir): raise RepositoryError("repository directory not available for %s" % (self._repository_id, )) return dump_dumpobj(nb_path, metadata, complete_path=True)
def _save_userdata(self, metadata): """ Save the given noticeboard metadata to disk. @param metadata: repository user metadata to store @type metadata: dict @raise KeyError: if given repository identifier is not available @raise RepositoryError: if given repository directory is not available """ avail_data = self._settings['repositories']['available'] nb_path = avail_data[self._repository_id]['local_notice_board'] nb_dir = os.path.dirname(nb_path) if not const_dir_writable(nb_dir): raise RepositoryError( "repository directory not available for %s" % ( self._repository_id,)) return dump_dumpobj(nb_path, metadata, complete_path = True)
def _get_authfile(self): """ Try to get the auth file. If it fails, return None. """ # setup auth file path home = os.getenv("HOME") auth_file = None if home is not None: if const_dir_writable(home): auth_file = os.path.join(home, AuthenticationStorage._AUTH_FILE) auth_dir = os.path.dirname(auth_file) if not os.path.isdir(auth_dir): try: os.makedirs(auth_dir, 0o700) const_setup_file(auth_dir, etpConst['entropygid'], 0o700) except (OSError, IOError): # ouch, no permissions auth_file = None return auth_file
def store_noticeboard_userdata(self, repository_id, metadata): """ Store given noticeboard metadata for given repository to disk. @param repository_id: repository identifier @type repository_id: string @param metadata: repository user metadata to store @type metadata: dict @raise KeyError: if given repository identifier is not available @raise RepositoryError: if given repository directory is not available """ repo_data = self._settings['repositories']['available'][repository_id] nb_path = repo_data['local_notice_board_userdata'] # check availability nb_dir = os.path.dirname(nb_path) if not const_dir_writable(nb_dir): raise RepositoryError( "repository directory not available for %s" % (repository_id,)) return dump_dumpobj(nb_path, metadata, complete_path = True)