def delete(self, dump_dir): ddir = report.dd_opendir(dump_dir) if not ddir: return not os.path.isdir(dump_dir) ddir.delete() return True
def _open_ddir(self, dump_dir, readonly=False): flags = 0 if readonly: flags |= report.DD_OPEN_READONLY ddir = report.dd_opendir(dump_dir, flags) if not ddir: raise problem.exception.InvalidProblem( 'Can\'t open directory: {0}'.format(dump_dir)) return ddir
def delete_problem(self, problem_id): dd = report.dd_opendir(problem_id) if not dd: # we can safely declare problem as deleted # if directory doesn't exist return not os.path.isdir(problem_id) # TODO : delete over abrtd dd.delete() self._watcher.unwatch_problem(problem_id) # dd.close() return True
def get_problems(self): for dir_entry in os.listdir(self.directory): problem_id = os.path.join(self.directory, dir_entry) if os.path.isdir(problem_id): dd = report.dd_opendir(problem_id) if dd is None: logging.debug("Omitted dir: '{0}'".format(problem_id)) else: logging.debug("Found dump dir: '{0}'".format(problem_id)) dd.close() yield problem_id else: logging.debug("Omitted path: '{0}'".format(problem_id))
def list(self, _all=False): for dir_entry in os.listdir(self.directory): dump_dir = os.path.join(self.directory, dir_entry) if not os.path.isdir(dump_dir) or not os.access(dump_dir, os.R_OK): continue uid = os.getuid() gid = os.getuid() dir_stat = os.stat(dump_dir) if not _all and (dir_stat.st_uid != uid and dir_stat.st_gid != gid): continue ddir = report.dd_opendir(dump_dir, report.DD_OPEN_READONLY) if ddir: ddir.close() yield dump_dir
def get_items(self, problem_id, *args): if not args: return {} dd = report.dd_opendir(problem_id, report.DD_OPEN_READONLY) if not dd: raise errors.InvalidProblem(problem_id, "Can't open directory: '{0}'".format(problem_id)) items = {} for field_name in args: value = dd.load_text(field_name, report.DD_FAIL_QUIETLY_ENOENT | report.DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE) if value: items[field_name] = value dd.close() return items
def get_items(self, problem_id, *args): if not args: return {} dd = report.dd_opendir(problem_id, report.DD_OPEN_READONLY) if not dd: raise errors.InvalidProblem( problem_id, "Can't open directory: '{0}'".format(problem_id)) items = {} for field_name in args: value = dd.load_text( field_name, report.DD_FAIL_QUIETLY_ENOENT | report.DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE) if value: items[field_name] = value dd.close() return items