Example #1
0
def copyAll(sourceRoot, destinationDirectory, onlyCopyNewerFiles=False, makeLinksInsteadOfCopying=False):
    fileList = listDirRecursive.listDirRecursive(sourceRoot, False)
    pathList = listDirRecursive.listDirRecursive(sourceRoot, True)
    
    linkString = ""
    for i in range(0,len(fileList)):
        # Build Path
        sourcePath = os.path.join(sourceRoot, pathList[i])

        # Copy Files
        if (os.path.isfile(sourcePath)):
            destPath = os.path.join(destinationDirectory, fileList[i])
            copyFile = True
            if (onlyCopyNewerFiles and os.path.exists(destPath)):
                if (os.path.getmtime(sourcePath) <= os.path.getmtime(destPath)):
                    copyFile = False
                
            if (copyFile):
                #print "Copying " + sourcePath + " to " + destPath + "."
                if (makeLinksInsteadOfCopying and subprocess.mswindows):
                    #symbolic links mklink <newfile> <oldfile>
                    #hard links fsutil hardlink create <newfile> <oldfile> (must be on the same volume)
                    if (linkString <> ""):
                        linkString = linkString + " && "
                    if (sourcePath.find(" ") <> -1):
                        sourcePath = "\"" + sourcePath + "\""
                    if (destPath.find(" ") <> -1):
                        destPath = "\"" + destPath + "\""
                    linkString = linkString + "fsutil hardlink create " + destPath + " " + sourcePath
                    
                else:
                    shutil.copyfile(sourcePath, destPath)

    if (linkString <> ""):
        print linkString
        p = subprocess.Popen([linkString],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
        outputTuple = p.communicate()
        outputText = outputTuple[0] + outputTuple[1]
        
        outputText = re.sub(r'\r\n', "\n", outputText)
        outputText = re.sub(r'Hardlink created for [a-zA-Z0-9_:\\<=> ]*\n', "", outputText)
        #outputText = re.sub(r'Compiling [a-zA-Z0-9_]*\n', "", outputText)
        #outputText = re.sub(r'Importing Defaults for [a-zA-Z0-9_]*\n', "", outputText)
         
        print outputText
def executeDynamicSourceFiles(sourceDirectory, deleteWhenDone=False):
    files = listDirRecursive.listDirRecursive(sourceDirectory, True)
    for filename in files:
        filepath = os.path.join(sourceDirectory, filename)
        if (filepath.endswith(".py")):
            print "Executing Python file " + filename
            subprocessExecute.executePythonFile(filepath, ".")
        elif (filepath.endswith(".lisp")):
            print "Executing Common Lisp file " + filename
            subprocessExecute.executeLispFile(filepath, ".", loadIndirectly=True)
    
    if deleteWhenDone:
        for filename in files:
            filepath = os.path.join(sourceDirectory, filename)
            if (not filename.endswith(".uc")):
                removeFile(filepath)
Example #3
0
def executeUnrealscriptTestCommandlets(sourceDirectory, modName, systemDirectory, uccPath):
    testConfigFileContents = bruteIO.readFile(os.path.join(systemDirectory, "ConfigTestMutator.ini"))

    testList = ""

    testConfigFileContents = addToStringIfNotPresent(testConfigFileContents, "[UnrealUtilityLib.ConfigTestMutator]\n")
    files = listDirRecursive.listDirRecursive(sourceDirectory, True)
    for filename in files:
        if filename.endswith("Tests.uc"):
            testList = testList + " " + modName + "." + filename[0 : -len(".uc")]
            testConfigFileContents = addToStringIfNotPresent(
                testConfigFileContents, 'testNames="' + modName + "." + filename[0 : -len(".uc")] + '"\n'
            )

    bruteIO.writeFile(os.path.join(systemDirectory, "ConfigTestMutator.ini"), testConfigFileContents)

    if not testList == "":
        subprocess.call([uccPath, "UnrealUtilityLib.ParameterTestCommandlet", testList])
Example #4
0
#!/usr/bin/python

# similar to make's wildcard operator, but getting all files in all subdirectories

import sys
import listDirRecursive
import os
import string

if len(sys.argv) < 1:
    print "Syntax: wildcard.py <root-directory>"
    sys.exit(0)

rootdirectory = sys.argv[1]
files = listDirRecursive.listDirRecursive(rootdirectory, True)

stringresult = ""
for file in files:
    if (stringresult <> ""):
        stringresult = stringresult + " "
    stringresult = stringresult + string.replace(os.path.join(rootdirectory, file), " ", "\\ ")
    
print stringresult