Esempio n. 1
0
def remote_untar(tarfile, remote_dir=None, delete=True):
    """Use internal Python tar package to untar a file in the current remote
    directory instead of assuming that tar exists on the remote machine.
    """
    tarfile = tarfile.replace("\\", "/")
    cmds = ["import tarfile", "tar = tarfile.open('%s')" % tarfile, "tar.extractall()", "tar.close()"]
    if delete:
        cmds.extend(["import os", 'os.remove("%s")' % tarfile])
    return remote_py_cmd(cmds, remote_dir=remote_dir)
Esempio n. 2
0
def remote_untar(tarfile, remote_dir=None, delete=True):
    """Use internal python tar package to untar a file in the current remote
    directory instead of assuming that tar exists on the remote machine.
    """
    tarfile = tarfile.replace('\\','/')
    cmds = [ "import tarfile",
             "tar = tarfile.open('%s')" % tarfile,
             "tar.extractall()",
             "tar.close()",
             ]
    if delete:
        cmds.extend(['import os', 'os.remove("%s")' % tarfile])
    return remote_py_cmd(cmds, remote_dir=remote_dir)