Esempio n. 1
0
def unpack_xpak(xpakfile, tmpdir = None):
    """
    docstring_title

    @param xpakfile: 
    @type xpakfile: 
    @keyword tmpdir: 
    @type tmpdir: 
    @return: 
    @rtype: 
    """
    if tmpdir is None:
        tmpdir = const_mkdtemp(prefix="unpack_xpak")
    elif not os.path.isdir(tmpdir):
        raise AttributeError("tmpdir %s does not exist" % (tmpdir,))
    try:
        xpakdata = xpak.getboth(xpakfile)
        xpak.xpand(xpakdata, tmpdir)
        return tmpdir
    except TypeError:
        return None
    finally:
        try:
            os.remove(xpakfile)
        except OSError:
            pass
Esempio n. 2
0
def unpack_xpak(xpakfile, tmpdir=None):
    """
    docstring_title

    @param xpakfile: 
    @type xpakfile: 
    @keyword tmpdir: 
    @type tmpdir: 
    @return: 
    @rtype: 
    """
    if tmpdir is None:
        tmpdir = const_mkdtemp(prefix="unpack_xpak")
    elif not os.path.isdir(tmpdir):
        raise AttributeError("tmpdir %s does not exist" % (tmpdir, ))
    try:
        xpakdata = xpak.getboth(xpakfile)
        xpak.xpand(xpakdata, tmpdir)
        return tmpdir
    except TypeError:
        return None
    finally:
        try:
            os.remove(xpakfile)
        except OSError:
            pass
Esempio n. 3
0
    def __init__(self):
        object.__init__(self)
        self.__dump_lock = threading.Lock()
        try:
            if not os.path.isdir(MtimePingus.PINGUS_DIR):
                os.makedirs(MtimePingus.PINGUS_DIR, 0o775)
                const_setup_perms(MtimePingus.PINGUS_DIR, etpConst["entropygid"])

        except (OSError, IOError):
            MtimePingus.PINGUS_DIR = const_mkdtemp(prefix="pingus_dir")
Esempio n. 4
0
    def __init__(self):
        object.__init__(self)
        self.__dump_lock = threading.Lock()
        try:
            if not os.path.isdir(MtimePingus.PINGUS_DIR):
                os.makedirs(MtimePingus.PINGUS_DIR, 0o775)
                const_setup_perms(MtimePingus.PINGUS_DIR,
                                  etpConst['entropygid'])

        except (
                OSError,
                IOError,
        ):
            MtimePingus.PINGUS_DIR = const_mkdtemp(prefix="pingus_dir")
Esempio n. 5
0
    def download_many(self, remote_paths, save_dir):

        if not remote_paths: # nothing to download
            return True

        def do_rmdir(path):
            try:
                shutil.rmtree(path, True)
            except (shutil.Error, OSError, IOError,):
                pass

        tmp_dir = const_mkdtemp(prefix="ssh_plugin.download_many")

        args = [EntropySshUriHandler._TXC_CMD]
        c_args, remote_str = self._setup_common_args(remote_paths.pop())
        args += c_args
        args += ["-B", "-P", str(self.__port)]
        args += [remote_str] + [self._setup_common_args(x)[1] for x in \
            remote_paths] + [tmp_dir]

        down_sts = self._fork_cmd(args) == os.EX_OK
        if not down_sts:
            do_rmdir(tmp_dir)
            return False

        # now move
        for tmp_file in os.listdir(tmp_dir):
            tmp_path = os.path.join(tmp_dir, tmp_file)
            save_path = os.path.join(save_dir, tmp_file)
            try:
                os.rename(tmp_path, save_path)
            except OSError:
                shutil.move(tmp_path, save_path)

        do_rmdir(tmp_dir)
        return True