Exemplo n.º 1
0
def eggifySingle(srcFS, src, destFS, dest, config=None):
    """ Eggify single source to single destination.

    Args:
        src (basestring)
        dest (basestring)

    Raises:
        MissingDestinationException
    """

    if dest is None:
        raise MissingDestinationException()

    if config is None:
        config = {}

    if src.startswith("/") or src[1] == ":":
        head, tail = os.path.split(src)

        srcFS = OSFS(head)
        src = tail

    if srcFS.isfile(unicode(src)):
        assertFS(destFS.getsyspath(unicode(dest)))

        workingDir = srcFS.getsyspath(unicode("/"))
        devnull = open(os.devnull, 'w')

        cmd = ["python", src, "bdist_egg"]

        if "purge" in config.keys() and config["purge"]:
            cmd.append("--exclude-source-files")            

        subprocess.check_call(cmd, cwd=workingDir, stdout=devnull, stderr=devnull)
    
        if srcFS.isdir(unicode("dist")):
            distFS = srcFS.opendir(unicode("dist"))

            for name in reversed(sorted(distFS.listdir("/"))):
                if name.endswith(".egg"):
                    destEggFS = destFS.opendir(unicode(dest))

                    # remove existing eggs
                    removeOldEggs(destEggFS, name)

                    eggSrcPath = distFS.getsyspath(unicode(name))
                    eggDestPath = destEggFS.getsyspath(unicode(name))

                    copy_file(distFS, unicode(name), destEggFS, unicode(name))

                    print "copied {} to {}".format(eggSrcPath, eggDestPath)

                    break
def compileFile(src, dest):
    """Compile src file to dest file.

    Args:
        src (basestring)
        dest (basestring)
    """

    assertFS(os.path.dirname(dest))

    py_compile.compile(src, dest)
def compileSingle(srcFS, src, destFS, dest):
    """Copy single source to single destination.

    Args:
        src (basestring)
        dest (basestring)

    Raises:
        MissingDestinationException
    """

    if dest is None:
        raise MissingDestinationException()

    if srcFS.exists(unicode(src)):
        if srcFS.isdir(unicode(src)):
            srcModuleFS = srcFS.opendir(unicode(src))
            destModuleFS = assertFS(destFS.getsyspath(unicode(dest)))

            for path in srcModuleFS.walk.files(filter=['*.py']):
                filename, extension = os.path.splitext(path)

                compiledPath = filename + ".pyc"

                compileFile(srcModuleFS.getsyspath(unicode(path)),
                            destModuleFS.getsyspath(unicode(compiledPath)))

        if srcFS.isfile(unicode(src)):
            compileFile(srcFS.getsyspath(unicode(src)),
                        destFS.getsyspath(unicode(dest)))
Exemplo n.º 4
0
def copySingle(srcFS, src, destFS, dest):
    """Copy single source to single destination.

    Args:
        src (basestring)
        dest (basestring)

    Raises:
        MissingDestinationException
    """

    if dest is None:
        raise MissingDestinationException()

    if srcFS.isdir(unicode(src)):
        assertFS(destFS.getsyspath(unicode(dest)))

        copy_fs(srcFS.opendir(unicode(src)), destFS.opendir(unicode(dest)))

    if srcFS.isfile(unicode(src)):
        assertFS(destFS.getsyspath(unicode(os.path.dirname(dest))))

        copy_file(srcFS, unicode(src), destFS, unicode(dest))    
Exemplo n.º 5
0
def GetDestFS(config):
    destinations = config["dest"]

    # create list of destinations
    if not isinstance(destinations, list):
        destinations = [destinations]

    def osFilter(path):
        if os.name == "nt":
            return path[1] == ":"
        else:
            return path.startswith("/")

    filteredDestinations = filter(osFilter, destinations)

    return [assertFS(x) for x in filteredDestinations]