Exemplo n.º 1
0
    def MapAndCleanPath(self, path):
        path = RepositoryUtils.CheckPathMapping(path)
        if SystemUtils.IsRunningOnWindows():
            path = path.replace("/", "\\")
            if path.startswith("\\") and not path.startswith("\\\\"):
                path = "\\" + path

        extension = os.path.splitext(path)[1]
        if extension == ".project":
            tempSceneDirectory = self.CreateTempDirectory(
                "thread" + str(self.GetThreadNumber()))
            tempSceneFileName = os.path.basename(path)
            tempSceneFilename = os.path.join(tempSceneDirectory,
                                             tempSceneFileName)
            RepositoryUtils.CheckPathMappingInFileAndReplace(
                path, tempSceneFilename, "", "")
            path = tempSceneFilename

        return path.replace("\\", "/")
    def PreRenderTasks(self):
        self.FailureMessage = ""
        self.Framecount = 0
        self.PreviousFrameTime = ""

        # Reset Slave Status Message between Tasks.
        self.SetStatusMessage("")

        # Check if we should be doing path mapping.
        sceneFilename = RepositoryUtils.CheckPathMapping(
            self.GetPluginInfoEntryWithDefault("SceneFile",
                                               self.GetDataFilename()))

        if SystemUtils.IsRunningOnMac():
            sceneFilename = sceneFilename.replace("\\", "/")
        else:
            sceneFilename = sceneFilename.replace("/", "\\")

        # We can only do path mapping on .aepx files (they're xml files).
        if (os.path.splitext(sceneFilename)[1]
            ).lower() == ".aepx" and self.GetBooleanConfigEntryWithDefault(
                "EnableAepxPathMapping", True):
            self.LogInfo("Performing path mapping on aepx project file")

            tempSceneDirectory = self.CreateTempDirectory(
                "thread" + str(self.GetThreadNumber()))
            tempSceneFileName = os.path.basename(sceneFilename)
            self.TempSceneFilename = os.path.join(tempSceneDirectory,
                                                  tempSceneFileName)

            if SystemUtils.IsRunningOnMac():
                RepositoryUtils.CheckPathMappingInFileAndReplace(
                    sceneFilename, self.TempSceneFilename,
                    ("\\", "platform=\"Win\""), ("/", "platform=\"MacPOSIX\""))
                os.chmod(self.TempSceneFilename,
                         os.stat(sceneFilename).st_mode)
            else:
                RepositoryUtils.CheckPathMappingInFileAndReplace(
                    sceneFilename, self.TempSceneFilename,
                    ("/", "platform=\"MacPOSIX\"", "\\>"),
                    ("\\", "platform=\"Win\"", "/>"))
                if SystemUtils.IsRunningOnLinux():
                    os.chmod(self.TempSceneFilename,
                             os.stat(sceneFilename).st_mode)
        else:
            self.TempSceneFilename = sceneFilename

        self.TempSceneFilename = PathUtils.ToPlatformIndependentPath(
            self.TempSceneFilename)

        # Get the path to the text file that forces After Effects to run the English version.
        if SystemUtils.IsRunningOnMac():
            myDocumentsPath = os.path.join(
                Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                "Documents/ae_force_english.txt")
        else:
            myDocumentsPath = os.path.join(
                Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                "ae_force_english.txt")

        # Check if we want to change After Effects to the English version. If we do, create the file.
        if self.GetBooleanConfigEntryWithDefault("ForceRenderingEnglish",
                                                 False):
            try:
                self.LogInfo(
                    "Attempting to create \"%s\" to force After Effects to run in English"
                    % myDocumentsPath)
                open(myDocumentsPath, 'w').close()
            except:
                self.LogWarning("Failed to create \"%s\" because %s" %
                                (myDocumentsPath, traceback.format_exc()))
        else:
            # If we don't want to force the English version, delete the file.
            if os.path.isfile(myDocumentsPath):
                try:
                    self.LogInfo(
                        "Attempting to delete \"%s\" to allow After Effects to run in the user's original language"
                        % myDocumentsPath)
                    os.remove(myDocumentsPath)
                except:
                    self.LogWarning("Failed to delete \"%s\" because %s" %
                                    (myDocumentsPath, traceback.format_exc()))

        myRePath = self.getAERenderOnlyFileName()

        # Check if we want to start After Effects in render engine mode. If we do, create the file. And important delete it later.
        if self.GetBooleanConfigEntryWithDefault("ForceRenderEngine", False):
            try:
                self.LogInfo(
                    "Attempting to create \"%s\" to force After Effects to run in Render Engine mode"
                    % myRePath)
                open(myRePath, 'w').close()
            except:
                self.LogWarning("Failed to create \"%s\" because %s" %
                                (myRePath, traceback.format_exc()))
        else:
            if self.GetBooleanConfigEntryWithDefault("DeleteRenderEngineFile",
                                                     False):
                # If we don't want to force in Render Engine mode, delete the file.
                if os.path.isfile(myRePath):
                    try:
                        self.LogInfo(
                            "Attempting to delete \"%s\" to allow After Effects to run in the workstation environment"
                            % myDocumentsPath)
                        os.remove(myRePath)
                    except:
                        self.LogWarning("Failed to delete \"%s\" because %s" %
                                        (myRePath, traceback.format_exc()))