Exemplo n.º 1
0
 def _exec_remove(self):
     for (mediainfo, pkgset, comment, touches) in self._remove_operations[:]:
         for pkg in pkgset.packages():
             srcpath = self.distro.package_path(mediainfo, pkg)
             srcdir = os.path.dirname(srcpath)
             filename = os.path.basename(srcpath)
             dstpath = os.path.join(self.storedir, filename)
             # TODO allow ignoring this kind of error
             if not os.path.exists(srcpath):
                 raise TransactionError("cannot find file: %s" %
                         (srcpath))
             if util.same_partition(self.storedir, srcdir):
                 logger.debug("renaming %s to %s", srcpath, dstpath)
                 try:
                     os.rename(srcpath, dstpath)
                 except EnvironmentError, e:
                     raise TransactionError("failed to move file from "
                             "%s to %s: %s" % (srcpath, dstpath, e))
             else:
                 cpcmd = self.config.get_copy_command()
                 cpcmd.append(srcpath)
                 cpcmd.append(dstpath)
                 logger.debug("running %s", cpcmd)
                 try:
                     cmd.run(cpcmd)
                 except cmd.CommandError, e:
                     raise TransactionError("failed to copy file from "
                         "%s to %s: %s" % (srcpath, dstpath, e))
                 logger.debug("unlinking %s", srcpath)
                 try:
                     os.unlink(srcpath)
                 except EnvironmentError, e:
                     raise TransactionError("failed to unlink %s: %s" %
                             (srcpath, e))
Exemplo n.º 2
0
 def _create_tmp_media(self, topdir, pkgset):
     basedir = os.path.join(topdir, self.config.smartcheck_tmp_media_dir)
     tmpname = time.strftime("%Y%m%d%H%M%S") + "-" + str(id(self))
     mediadir = os.path.join(basedir, tmpname)
     self._symlink_packages(mediadir, pkgset)
     args = self.config.get_genhdlist_command()
     args.append(mediadir)
     cmd.run(args) # let it throw CommandError
     return mediadir
Exemplo n.º 3
0
 def _exec_install(self):
     params = []
     for (media, pkgset, comment, touches) in self._install_operations[:]:
         for pkg in pkgset.packages():
             srcdir = os.path.dirname(pkg.path)
             if not os.path.exists(pkg.path):
                 raise TransactionError("cannot find %s" % (pkg.path))
             if not os.access(srcdir, os.W_OK):
                 raise TransactionError("no write permission for %s" %
                         (pkg.path))
             dstpath = self.distro.package_path(media, pkg)
             dstdir = os.path.dirname(os.path.abspath(dstpath))
             if not os.access(dstdir, os.W_OK):
                 raise TransactionError("no write permission for the "
                         "destination directory: %s" % (dstdir))
     paths = set()
     for (media, pkgset, comment, touches) in self._install_operations[:]:
         for pkg in pkgset.packages():
             if pkg.path in paths:
                 # prevent collision between operations that may involve
                 # the same file (the default install action vs. the
                 # debug package filter)
                 continue
             else:
                 paths.add(pkg.path)
             dstpath = self.distro.package_path(media, pkg)
             dstdir = os.path.dirname(os.path.abspath(dstpath))
             srcdir = os.path.dirname(os.path.abspath(pkg.path))
             if not os.path.exists(pkg.path):
                 raise TransactionError("cannot find file: %s" %
                         (pkg.path))
             if util.same_partition(srcdir, dstdir):
                 logger.debug("renaming %s to %s", pkg.path, dstpath)
                 try:
                     os.rename(pkg.path, dstpath)
                 except EnvironmentError, e:
                     raise TransactionError("failed to move file from "
                             "%s to %s: %s" % (pkg.path, dstpath, e))
             else:
                 cpcmd = self.config.get_copy_command()
                 cpcmd.append(pkg.path)
                 cpcmd.append(dstpath)
                 logger.debug("running command %s", cpcmd)
                 try:
                     cmd.run(cpcmd)
                 except cmd.CommandError, e:
                     raise TransactionError("failed to copy file from "
                         "%s to %s: %s" % (pkg.path, dstpath, e))
             try:
                 args = self.config.get_chmod_command()
                 args.append(self.config.package_copy_mode)
                 args.append(dstpath)
                 cmd.run(args)
             except cmd.CommandError, e:
                 raise TransactionError("failed to set permissions "
                         "for %s: %s" % (dstpath, e))
Exemplo n.º 4
0
 def _ensure_smart_medias_exist(self, topdir, mediaset):
     import yaml
     datadir = os.path.join(topdir, self.config.smartcheck_datadir)
     args = self.config.get_smart_command(datadir, "channel", ["--yaml"])
     logger.debug("running %s", args)
     output, status = cmd.run(args)
     medianames = frozenset(self._make_channel_name(mi)
                             for mi in mediaset.medias())
     try:
         smartmedias = yaml.load(output)
     except yaml.YAMLError, e:
         raise FilterError("failed to parse YAML smart output: %s" %
                 (e))
Exemplo n.º 5
0
 def update(self):
     args = self.config.get_genhdlist_command()
     args.append(self.path)
     logger.debug("updating medias with %s", args)
     output, _ = cmd.run(args)
     logger.debug("genhdlist repr(output): %r", output)