def __get_catalog(self, name):
"""Private method to retrieve catalog; this bypasses the
normal automatic caching (unless the image hasn't been
upgraded yet)."""
croot = os.path.join(self._statedir, name)
try:
os.makedirs(croot)
except EnvironmentError as e:
if e.errno in (errno.EACCES, errno.EROFS):
# Allow operations to work for
# unprivileged users.
croot = None
elif e.errno != errno.EEXIST:
raise
# batch_mode is set to True here as any operations that modify
# the catalogs (add or remove entries) are only done during an
# image upgrade or metadata refresh. In both cases, the catalog
# is resorted and finalized so this is always safe to use.
cat = pkg.catalog.Catalog(batch_mode=True, meta_root=croot,
sign=False, file_root=self.imgdir)
return cat
评论列表
文章目录