Ejemplo n.º 1
0
def targetPathToName(path):
    name = ""
    path = path.strip()

    if git.isGitRepo(path):
        if os.path.isdir(path):
            name = os.path.basename(path)
        elif utilityFunctions.isURL(path):
            name = utilityFunctions.URLToFilename(path)
            if name.endswith(".git"):
                name = name[:-4]
    elif svn.isSvnRepo(path):
        if path.endswith(os.sep):
            path = path[:-1]
        if path.endswith("/trunk") or path.endswith("\trunk"):
            path = path[:-6]
        if os.path.isdir(path):
            name = os.path.basename(path)
        elif utilityFunctions.isURL(path):
            name = utilityFunctions.URLToFilename(path)
    elif utilityFunctions.isURL(path):
        name = utilityFunctions.URLToFilename(path)
        name = utilityFunctions.splitFileName(name)[0]
    elif os.path.isfile(path) and utilityFunctions.validateCompressedFile(path, logger):
        name = utilityFunctions.splitFileName(path)[0]
    elif os.path.isdir(path):
        if path.endswith(os.sep):
            name = os.path.basename(path[:-1])
        else:
            name = os.path.basename(path)
    else:
        logger.writeError("Could not convert given target path to name: " + path)
    return name
Ejemplo n.º 2
0
def unpack(pythonCallInfo):
    if os.path.isfile(pythonCallInfo.target.path):
        if not utilityFunctions.validateCompressedFile(pythonCallInfo.target.path):
            pythonCallInfo.success = False
        else:
            if tarfile.is_tarfile(pythonCallInfo.target.path):
                utilityFunctions.untar(pythonCallInfo.target.path, pythonCallInfo.target.outputPath, True)
                pythonCallInfo.target.path = pythonCallInfo.target.outputPath
                pythonCallInfo.success = True
            elif zipfile.is_zipfile(pythonCallInfo.target.path):
                utilityFunctions.unzip(pythonCallInfo.target.path, pythonCallInfo.target.outputPath, True)
                pythonCallInfo.target.path = pythonCallInfo.target.outputPath
                pythonCallInfo.success = True
    elif os.path.isdir(pythonCallInfo.target.path):
        pythonCallInfo.success = True
    else:
        pythonCallInfo.logger.writeError("Given path '" + pythonCallInfo.target.path + "' not understood by MixDown's unpack (path should be a file or a directory at this point)")
        pythonCallInfo.success = False

    return pythonCallInfo