Exemplo n.º 1
0
 def SaveList(self, exportlist, week, path, price, publisher):
     if path:
         print "Creating file"
         w = StreamWriter(path, False)
         w.WriteLine("Checklist for week of " + week)
         w.WriteLine()
         w.WriteLine()
         for item in exportlist:
             w.Write("[] ")
             if publisher:
                 w.Write(item["Publisher"] + " ")
             w.Write(item["Title"])
             if price:
                 w.Write(" " + item["Price"])
             w.WriteLine()
         w.Close()
         w.Dispose()
Exemplo n.º 2
0
class SharedParametersFileClass():

	def __init__(self, filePath, uidoc):
		self.filePath = filePath
		self.uidoc = uidoc
	
		try:
			self.filereader = StreamReader( filePath )
			self.uidoc.Application.Application.OpenSharedParameterFile()
		except:
			Alert(
				'Check Your Shared Parameters File Path', 
				title="Error", 
				header="Invalid Shared Parameters File",
				exit=True
			)

		self.temp = os.environ['USERPROFILE'] + "\\AppData\\Local\\temp.txt"


	def __enter__(self):
		self.file = StreamWriter( self.temp )
		while self.filereader.Peek() > -1:
			line = self.filereader.ReadLine()
			if line.startswith(('*', '#', 'META')):
				self.file.WriteLine( line )
		self.file.Close()

		self.uidoc.Application.Application.SharedParametersFilename = self.temp
		self.fileDefinition = self.uidoc.Application.Application.OpenSharedParameterFile()
		self.groupDefinition = self.fileDefinition.Groups.Create('temp_group')

		return self


	def __exit__(self, type, value, traceback):
		Delete( self.temp )
		self.uidoc.Application.Application.SharedParametersFilename = self.filePath


	def copyExternalDefinition(self, guid, definition):
		xDefOptions = ExternalDefinitionCreationOptions(definition.Name, definition.ParameterType)
		xDefOptions.Description = ''
		xDefOptions.GUID = guid

		return self.groupDefinition.Definitions.Create( xDefOptions )
def SubmitButtonPressed(*args):
    global scriptDialog
    global integration_dialog

    try:
        submitScene = scriptDialog.GetValue("SubmitSceneBox")

        # Check if Integration options are valid
        if not integration_dialog.CheckIntegrationSanity():
            return

        warnings = []
        errors = []

        # Check if max files exist.
        sceneFiles = StringUtils.FromSemicolonSeparatedString(
            scriptDialog.GetValue("SceneBox"), False)
        if not sceneFiles:
            errors.append("No 3dsmax file specified")

        for sceneFile in sceneFiles:
            if not File.Exists(sceneFile):
                errors.append("3dsmax file %s does not exist" % sceneFile)
                return
            elif not submitScene and PathUtils.IsPathLocal(sceneFile):
                warnings.append(
                    "The scene file " + sceneFile +
                    " is local and is not being submitted with the job, are you sure you want to continue?"
                )

        # Check if path config file exists.
        pathConfigFile = scriptDialog.GetValue("PathConfigBox").strip()
        if pathConfigFile:
            if not File.Exists(pathConfigFile):
                errors.append("Path configuration file %s does not exist" %
                              pathConfigFile)

        # Check if PreLoad script file exists.
        preLoadFile = scriptDialog.GetValue("PreLoadBox").strip()
        if preLoadFile:
            if not File.Exists(preLoadFile):
                errors.append("PreLoad MAXScript file %s does not exist" %
                              preLoadFile)

        # Check if PostLoad script file exists.
        postLoadFile = scriptDialog.GetValue("PostLoadBox").strip()
        if postLoadFile:
            if not File.Exists(postLoadFile):
                errors.append("PostLoad MAXScript file %s does not exist" %
                              postLoadFile)

        # Check if PreFrame script file exists.
        preFrameFile = scriptDialog.GetValue("PreFrameBox").strip()
        if preFrameFile:
            if not File.Exists(preFrameFile):
                errors.append("PreFrame MAXScript file %s does not exist" %
                              preFrameFile)

        # Check if PostFrame script file exists.
        postFrameFile = scriptDialog.GetValue("PostFrameBox").strip()
        if postFrameFile:
            if not File.Exists(postFrameFile):
                errors.append("PostFrame MAXScript file %s does not exist" %
                              postFrameFile)

        # Check if a valid frame range has been specified.
        frames = scriptDialog.GetValue("FramesBox")
        if scriptDialog.GetValue("DBRModeBox") != "Disabled":
            frameArray = FrameUtils.Parse(frames)
            if len(frameArray) != 1:
                errors.append(
                    "Please specify a single frame for distributed rendering in the Frame List."
                )
            elif not FrameUtils.FrameRangeValid(frames):
                errors.append(
                    "Please specify a valid single frame for distributed rendering in the Frame List."
                )

            frames = "0-" + str(scriptDialog.GetValue("DBRServersBox") - 1)
        else:
            if not FrameUtils.FrameRangeValid(frames):
                errors.append("Frame range %s is not valid" % frames)

        # If using 'select GPU device Ids' then check device Id syntax is valid
        if scriptDialog.GetValue(
                "GPUsPerTaskBox") == 0 and scriptDialog.GetValue(
                    "GPUsSelectDevicesBox"):
            regex = re.compile("^(\d{1,2}(,\d{1,2})*)?$")
            validSyntax = regex.match(
                scriptDialog.GetValue("GPUsSelectDevicesBox"))
            if not validSyntax:
                errors.append(
                    "'Select GPU Devices' syntax is invalid!\nTrailing 'commas' if present, should be removed.\nValid Examples: 0 or 2 or 0,1,2 or 0,3,4 etc"
                )

            # Check if concurrent threads > 1
            if scriptDialog.GetValue("ConcurrentTasksBox") > 1:
                errors.append(
                    "If using 'Select GPU Devices', then 'Concurrent Tasks' must be set to 1"
                )

        if errors:
            scriptDialog.ShowMessageBox(
                "The following errors were encountered:\n\n%s\n\nPlease resolve these issues and submit again.\n"
                % ("\n\n".join(errors)), "Errors")
            return

        if warnings:
            result = scriptDialog.ShowMessageBox(
                "Warnings:\n\n%s\n\nDo you still want to continue?" %
                ("\n\n".join(warnings)), "Warnings", ("Yes", "No"))
            if result == "No":
                return

        successes = 0
        failures = 0

        # Submit each scene file separately.
        for sceneFile in sceneFiles:
            jobName = scriptDialog.GetValue("NameBox")
            if len(sceneFiles) > 1:
                jobName = jobName + " [" + Path.GetFileName(sceneFile) + "]"

            # Create job info file.
            jobInfoFilename = Path.Combine(ClientUtils.GetDeadlineTempPath(),
                                           "max_job_info.job")
            writer = StreamWriter(jobInfoFilename, False, Encoding.Unicode)
            writer.WriteLine("Plugin=3dsmax")
            writer.WriteLine("Name=%s" % jobName)
            writer.WriteLine("Comment=%s" %
                             scriptDialog.GetValue("CommentBox"))
            writer.WriteLine("Department=%s" %
                             scriptDialog.GetValue("DepartmentBox"))
            writer.WriteLine("Pool=%s" % scriptDialog.GetValue("PoolBox"))
            writer.WriteLine("SecondaryPool=%s" %
                             scriptDialog.GetValue("SecondaryPoolBox"))
            writer.WriteLine("Group=%s" % scriptDialog.GetValue("GroupBox"))
            writer.WriteLine("Priority=%s" %
                             scriptDialog.GetValue("PriorityBox"))
            writer.WriteLine("TaskTimeoutMinutes=%s" %
                             scriptDialog.GetValue("TaskTimeoutBox"))
            writer.WriteLine("EnableAutoTimeout=%s" %
                             scriptDialog.GetValue("AutoTimeoutBox"))
            writer.WriteLine("ConcurrentTasks=%s" %
                             scriptDialog.GetValue("ConcurrentTasksBox"))
            writer.WriteLine("LimitConcurrentTasksToNumberOfCpus=%s" %
                             scriptDialog.GetValue("LimitConcurrentTasksBox"))

            writer.WriteLine("MachineLimit=%s" %
                             scriptDialog.GetValue("MachineLimitBox"))
            if scriptDialog.GetValue("IsBlacklistBox"):
                writer.WriteLine("Blacklist=%s" %
                                 scriptDialog.GetValue("MachineListBox"))
            else:
                writer.WriteLine("Whitelist=%s" %
                                 scriptDialog.GetValue("MachineListBox"))

            writer.WriteLine("LimitGroups=%s" %
                             scriptDialog.GetValue("LimitGroupBox"))
            writer.WriteLine("JobDependencies=%s" %
                             scriptDialog.GetValue("DependencyBox"))
            writer.WriteLine("OnJobComplete=%s" %
                             scriptDialog.GetValue("OnJobCompleteBox"))

            if scriptDialog.GetValue("SubmitSuspendedBox"):
                writer.WriteLine("InitialStatus=Suspended")

            writer.WriteLine("Frames=%s" % frames)
            if scriptDialog.GetValue("DBRModeBox") == "Disabled":
                writer.WriteLine("ChunkSize=%s" %
                                 scriptDialog.GetValue("ChunkSizeBox"))

            # Integration
            extraKVPIndex = 0
            groupBatch = False

            if integration_dialog.IntegrationProcessingRequested():
                extraKVPIndex = integration_dialog.WriteIntegrationInfo(
                    writer, extraKVPIndex)
                groupBatch = groupBatch or integration_dialog.IntegrationGroupBatchRequested(
                )

            if groupBatch:
                writer.WriteLine("BatchName=%s\n" % jobName)

            writer.Close()

            # Create plugin info file.
            pluginInfoFilename = Path.Combine(
                ClientUtils.GetDeadlineTempPath(), "max_plugin_info.job")
            writer = StreamWriter(pluginInfoFilename, False, Encoding.Unicode)

            writer.WriteLine("Version=%s" %
                             scriptDialog.GetValue("VersionBox"))
            writer.WriteLine("IsMaxDesign=%s" %
                             scriptDialog.GetValue("IsMaxDesignBox"))

            if int(scriptDialog.GetValue("VersionBox")) < 2014:
                writer.WriteLine("MaxVersionToForce=%s" %
                                 scriptDialog.GetValue("BuildBox"))
                writer.WriteLine("MaxVersionToForce0=None")
                writer.WriteLine("MaxVersionToForce1=32bit")
                writer.WriteLine("MaxVersionToForce2=64bit")

            writer.WriteLine("UseSlaveMode=%d" %
                             (not scriptDialog.GetValue("WorkstationModeBox")))
            if scriptDialog.GetValue("WorkstationModeBox"):
                writer.WriteLine("UseSilentMode=%s" %
                                 (scriptDialog.GetValue("SilentModeBox")))
            else:
                writer.WriteLine("UseSilentMode=False")

            writer.WriteLine("ShowFrameBuffer=%s" %
                             scriptDialog.GetValue("ShowVfbBox"))
            writer.WriteLine("RemovePadding=%s" %
                             scriptDialog.GetValue("RemovePaddingBox"))
            writer.WriteLine("RestartRendererMode=%s" %
                             scriptDialog.GetValue("RestartRendererBox"))
            writer.WriteLine(
                "IgnoreMissingExternalFiles=%s" %
                scriptDialog.GetValue("IgnoreMissingExternalFilesBox"))
            writer.WriteLine("IgnoreMissingUVWs=%s" %
                             scriptDialog.GetValue("IgnoreMissingUVWsBox"))
            writer.WriteLine("IgnoreMissingXREFs=%s" %
                             scriptDialog.GetValue("IgnoreMissingXREFsBox"))
            writer.WriteLine("IgnoreMissingDLLs=%s" %
                             scriptDialog.GetValue("IgnoreMissingDLLsBox"))
            writer.WriteLine("LocalRendering=%s" %
                             scriptDialog.GetValue("LocalRenderingBox"))
            writer.WriteLine("DisableMultipass=%s" %
                             scriptDialog.GetValue("DisableMultipassBox"))
            writer.WriteLine("OneCpuPerTask=%s" %
                             scriptDialog.GetValue("OneCpuPerTaskBox"))

            if pathConfigFile:
                writer.WriteLine("PathConfigFile=%s" %
                                 Path.GetFileName(pathConfigFile))
                writer.WriteLine("MergePathConfigFile=%s" %
                                 scriptDialog.GetValue("MergePathConfigBox"))

            if preLoadFile:
                writer.WriteLine("PreLoadScript=%s" %
                                 Path.GetFileName(preLoadFile))

            if postLoadFile:
                writer.WriteLine("PostLoadScript=%s" %
                                 Path.GetFileName(postLoadFile))

            if preFrameFile:
                writer.WriteLine("PreFrameScript=%s" %
                                 Path.GetFileName(preFrameFile))

            if postFrameFile:
                writer.WriteLine("PostFrameScript=%s" %
                                 Path.GetFileName(postFrameFile))

            pluginIniOverride = scriptDialog.GetValue("PluginIniBox").strip()
            if pluginIniOverride:
                writer.WriteLine("OverridePluginIni=%s" % pluginIniOverride)

            writer.WriteLine("GammaCorrection=%s" %
                             scriptDialog.GetValue("GammaCorrectionBox"))
            writer.WriteLine("GammaInput=%s" %
                             scriptDialog.GetValue("GammaInputBox"))
            writer.WriteLine("GammaOutput=%s" %
                             scriptDialog.GetValue("GammaOutputBox"))

            if int(scriptDialog.GetValue("VersionBox")) >= 2013:
                if scriptDialog.GetValue("OverrideLanguageBox"):
                    writer.WriteLine("Language=%s" %
                                     scriptDialog.GetValue("LanguageBox"))
                else:
                    writer.WriteLine("Language=Default")

            camera = scriptDialog.GetValue("CameraBox")
            if camera:
                writer.WriteLine("Camera=%s" % camera)
                writer.WriteLine("Camera0=")
                writer.WriteLine("Camera1=%s" % camera)

            if not submitScene:
                writer.WriteLine("SceneFile=%s" % sceneFile)

            if scriptDialog.GetValue("DBRModeBox") != "Disabled":
                if scriptDialog.GetValue("DBRModeBox") == "VRay DBR":
                    writer.WriteLine("VRayDBRJob=True")
                elif scriptDialog.GetValue(
                        "DBRModeBox") == "Mental Ray Satellite":
                    writer.WriteLine("MentalRayDBRJob=True")
                elif scriptDialog.GetValue("DBRModeBox") == "VRay RT DBR":
                    writer.WriteLine("VRayRtDBRJob=True")
                writer.WriteLine("DBRJobFrame=%s" %
                                 scriptDialog.GetValue("FramesBox"))

            if scriptDialog.GetValue("DBRModeBox") == "Disabled":
                writer.WriteLine("GPUsPerTask=%s" %
                                 scriptDialog.GetValue("GPUsPerTaskBox"))
                writer.WriteLine("GPUsSelectDevices=%s" %
                                 scriptDialog.GetValue("GPUsSelectDevicesBox"))

            writer.Close()

            # Setup the command line arguments.
            arguments = [jobInfoFilename, pluginInfoFilename]
            if scriptDialog.GetValue("SubmitSceneBox"):
                arguments.append(sceneFile)

            if pathConfigFile:
                arguments.append(pathConfigFile)
            if preLoadFile:
                arguments.append(preLoadFile)
            if postLoadFile:
                arguments.append(postLoadFile)
            if preFrameFile:
                arguments.append(preFrameFile)
            if postFrameFile:
                arguments.append(postFrameFile)

            if len(sceneFiles) == 1:
                results = ClientUtils.ExecuteCommandAndGetOutput(arguments)
                scriptDialog.ShowMessageBox(results, "Submission Results")
            else:
                # Now submit the job.
                exitCode = ClientUtils.ExecuteCommand(arguments)
                if exitCode == 0:
                    successes += 1
                else:
                    failures += 1

        if len(sceneFiles) > 1:
            scriptDialog.ShowMessageBox(
                "Jobs submitted successfully: %d\nJobs not submitted: %d" %
                (successes, failures), "Submission Results")
    except:
        scriptDialog.ShowMessageBox(traceback.format_exc(), "")
Exemplo n.º 4
0
    wtr = StreamWriter(stream)
    wtr.AutoFlush = True
    strInput = StringBuilder()

    #Setup/start process
    p = Process()
    p.StartInfo.FileName = "cmd.exe"
    p.StartInfo.CreateNoWindow = True
    p.StartInfo.UseShellExecute = False
    p.StartInfo.RedirectStandardOutput = True
    p.StartInfo.RedirectStandardInput = True
    p.StartInfo.RedirectStandardError = True
    p.OutputDataReceived += DataReceivedEventHandler(CmdOutputDataHandler)
    p.ErrorDataReceived += DataReceivedEventHandler(CmdOutputDataHandler)
    p.Start()
    wtr.WriteLine("SPID: %s\nCPID: %s" %
                  (Process.GetCurrentProcess().Id, p.Id))

    p.BeginErrorReadLine()
    p.BeginOutputReadLine()

    while (not p.HasExited):
        try:
            strInput.Append.Overloads[str](rdr.ReadLine())
            if strInput.ToString().ToLower() == "exit":
                p.Kill()
                Process.GetCurrentProcess().Kill()
            else:
                p.StandardInput.WriteLine(strInput)
            strInput.Remove(0, strInput.Length)
        except:
            break
Exemplo n.º 5
0
    def _submit_button_pressed( self, *args ):
        """
        Callback for the "submit" button. Submits a job to Deadline
        :param args:
        :return:
        """
        warnings = []
        errors = []

        # If using 'select GPU device Ids' then check device Id syntax is valid.
        if self.GetValue( "GPUsPerTaskBox" ) == 0 and self.GetValue( "GPUsSelectDevicesBox" ) != "":
            # regex = re.compile( "^(\d{1,2}(,\d{1,2})*)?$" ) # Multiple gpu check
            regex = re.compile( "^([0-9]|1[0-6])$" ) # Single gpu check (Altus 1.8 currently only supports 1 gpu)

            valid_syntax = regex.match( self.GetValue( "GPUsSelectDevicesBox" ) )
            if not valid_syntax:
                # errors.append( "'Select GPU Devices' syntax is invalid!\nTrailing 'commas' if present, should be removed.\nValid Examples: 0 or 2 or 0,1,2 or 0,3,4 etc" ) # Multiple gpu check
                errors.append( "'Select GPU Device' syntax is invalid!\nSingle GPU ID 0-16 supported only.\nValid Examples: 0 or 1 or 2 etc" ) # Single gpu check (Altus 1.8 currently only supports 1 gpu per thread)

            # Check if concurrent threads > 1.
            if self.GetValue( "ConcurrentTasksBox" ) > 1:
                errors.append( "If using 'Select GPU Devices', then 'Concurrent Tasks' must be set to 1" )

        stereo_enabled = self.GetValue( "StereoBox" )
        version = float( self.GetValue( "VersionBox" ) )
        full_output_path = self.GetValue( "OutputBox" )
        use_config = self.GetValue( "configCheck" )

        # Check if a valid frame range has been specified.
        frames = self.GetValue( "FramesBox" )
        if not FrameUtils.FrameRangeValid( frames ):
            errors.append( "Frame range: %s is not valid" % frames )

        if not full_output_path:
            errors.append( "The output image name is required." )

        self._check_output_destination( errors, warnings )

        if use_config:
            self._check_config_input( errors, warnings )
        else:
            self._check_file_inputs( errors, warnings )

        # Check if Integration options are valid.
        if not self.integration_dialog.CheckIntegrationSanity( full_output_path ):
            return

        if errors:
            self.ShowMessageBox( "The following errors were encountered:\n\n%s\n\nPlease resolve these issues and submit again.\n" % ( "\n".join( errors ) ), "Errors" )
            return

        if warnings:
            result = self.ShowMessageBox( "Warnings:\n\n%s\n\nDo you still want to continue?" % ( "\n".join( warnings ) ), "Warnings", ( "Yes","No" ) )
            if result == "No":
                return

        # Create job info file.
        job_info_file = os.path.join( ClientUtils.GetDeadlineTempPath(), "altus_job_info.job" )
        writer = StreamWriter( job_info_file, False, Encoding.Unicode )
        writer.WriteLine( "Plugin=Altus" )
        writer.WriteLine( "Name=%s" % self.GetValue( "NameBox" ) )
        writer.WriteLine( "Comment=%s" % self.GetValue( "CommentBox" ) )
        writer.WriteLine( "Department=%s" % self.GetValue( "DepartmentBox" ) )
        writer.WriteLine( "Pool=%s" % self.GetValue( "PoolBox" ) )
        writer.WriteLine( "SecondaryPool=%s" % self.GetValue( "SecondaryPoolBox" ) )
        writer.WriteLine( "Group=%s" % self.GetValue( "GroupBox" ) )
        writer.WriteLine( "Priority=%s" % self.GetValue( "PriorityBox" ) )
        writer.WriteLine( "TaskTimeoutMinutes=%s" % self.GetValue( "TaskTimeoutBox" ) )
        writer.WriteLine( "EnableAutoTimeout=%s" % self.GetValue( "AutoTimeoutBox" ) )
        writer.WriteLine( "ConcurrentTasks=%s" % self.GetValue( "ConcurrentTasksBox" ) )
        writer.WriteLine( "LimitConcurrentTasksToNumberOfCpus=%s" % self.GetValue( "LimitConcurrentTasksBox" ) )

        writer.WriteLine( "MachineLimit=%s" % self.GetValue( "MachineLimitBox" ) )
        if self.GetValue( "IsBlacklistBox" ):
            writer.WriteLine( "Blacklist=%s" % self.GetValue( "MachineListBox" ) )
        else:
            writer.WriteLine( "Whitelist=%s" % self.GetValue( "MachineListBox" ) )

        writer.WriteLine( "LimitGroups=%s" % self.GetValue( "LimitGroupBox" ) )
        writer.WriteLine( "JobDependencies=%s" % self.GetValue( "DependencyBox" ) )
        writer.WriteLine( "OnJobComplete=%s" % self.GetValue( "OnJobCompleteBox" ) )

        full_output_path = full_output_path.replace( "\\", "/" )
        writer.WriteLine( "OutputFilename0=%s" % full_output_path )

        if self.GetValue( "SubmitSuspendedBox" ):
            writer.WriteLine( "InitialStatus=Suspended" )

        writer.WriteLine( "Frames=%s" % frames )
        writer.WriteLine( "ChunkSize=%s" % self.GetValue( "ChunkSizeBox" ) )

        extra_kvp_index = 0
        group_batch = False
        if self.integration_dialog.IntegrationProcessingRequested():
            extra_kvp_index = self.integration_dialog.WriteIntegrationInfo( writer, extra_kvp_index )
            group_batch = group_batch or self.integration_dialog.IntegrationGroupBatchRequested()

        if group_batch:
            writer.WriteLine( "BatchName=%s" % ( self.GetValue( "NameBox" ) ) )

        writer.Close()

        # Create plugin info file.
        plugin_info_file = os.path.join( ClientUtils.GetDeadlineTempPath(), "altus_plugin_info.job" )
        writer = StreamWriter( plugin_info_file, False, Encoding.Unicode )

        exe_type = self.GetValue( "ExecutableTypeBox" )
        writer.WriteLine( "ExecutableType=%s" % exe_type )

        writer.WriteLine( "Version=%s" % version )
        writer.WriteLine( "OutputFile=%s" % full_output_path )

        if exe_type in [ "OpenCl", "GPU", "Auto Select" ]:
            writer.WriteLine( "GPUsPerTask=%s" % self.GetValue( "GPUsPerTaskBox" ) )
            writer.WriteLine( "GPUsSelectDevices=%s" % self.GetValue( "GPUsSelectDevicesBox" ) )

        # If config file defined, then skip all other settings.
        if use_config:
            writer.WriteLine( "Config=%s" % self.GetValue( "ConfigBox" ) )
        else:
            for passType in AltusSubmissionDialog.PASS_TYPES:
                if self._pass_enabled( passType ):
                    writer.WriteLine( "%sFiles=%s;" % ( passType, self.GetValue( "%sBox" % passType ) ) )

            writer.WriteLine( "Renderer=%s" % self.GetValue( "RendererBox" ) )
            writer.WriteLine( "PreserveLayers=%s" % self.GetValue( "LayerPreservationBox" ) )
            writer.WriteLine( "OutputQuality=%s" % self.GetValue( "QualityBox" ) )
            writer.WriteLine( "AOVQuality=%s" % self.GetValue( "AOVQualityBox" ) )
            writer.WriteLine( "FrameRadius=%s" % self.GetValue( "FrameRadiusBox" ) )
            writer.WriteLine( "FilterRadius=%s" % self.GetValue( "FilterRadiusBox" ) )
            writer.WriteLine( "Kc_1=%s" % self.GetValue( "Kc1Box" ) )
            writer.WriteLine( "Kc_2=%s" % self.GetValue( "Kc2Box" ) )
            writer.WriteLine( "Kc_4=%s" % self.GetValue( "Kc4Box" ) )
            writer.WriteLine( "Kf=%s" % self.GetValue( "KfBox" ) )
            writer.WriteLine( "Stereo=%s" % stereo_enabled )
            if version == 1.8:
                # 1.8 is either False (Level 0) or True (Level 3)
                writer.WriteLine( "ForceContinue=%s" % bool( self.GetValue( "ForceContinueIntBox" )[ 0 ] ) )
            else:
                writer.WriteLine( "ForceContinueInt=%s" % self.GetValue( "ForceContinueIntBox" )[ 0 ] ) # Just need first character

            # Tile options
            writer.WriteLine( "Tile=%s" % self.GetValue( "TileBox" ) )
            writer.WriteLine( "TileSize=%s" % self.GetValue( "TileSizeBox" ) )

            writer.WriteLine( "FireFly=%s" % self.GetValue( "FireFlyBox" ) )

            if version >= 1.9:
                writer.WriteLine( "SkipFrameRadius=%s" % self.GetValue( "SkipFrameRadiusBox" ) )
                writer.WriteLine( "IgnoreAlpha=%s" % self.GetValue( "IgnoreAlphaBox" ) )

            if version >= 2.1:
                writer.WriteLine( "SinglePass=%s" % self.GetValue( "SinglePassBox" ) )

            if version >= 2.3:
                writer.WriteLine( "Force16bitOutput=%s" % self.GetValue( "Force16bitOutputBox" ) )
                writer.WriteLine( "EXRCompression=%s" % self.GetValue( "EXRCompressionBox" ) )

        writer.Close()

        # Setup the command line arguments.
        arguments = [ job_info_file, plugin_info_file ]

        # Now submit the job.
        results = ClientUtils.ExecuteCommandAndGetOutput( arguments )
        self.ShowMessageBox( results, "Submission Results" )
Exemplo n.º 6
0
def SubmitButtonPressed(*args):
    global scriptDialog
    global jobOptionsDialog
    global submittedFromMonitor
    global imageRender
    global outputFile
    global rndFileName

    warnings = []
    errors = []

    # Check if Mistika VR render files exist.
    sceneFiles = StringUtils.FromSemicolonSeparatedString(
        scriptDialog.GetValue("SceneBox"), False)
    if len(sceneFiles) == 0:
        errors.append("No Mistika VR render file specified.")

    submitScene = scriptDialog.GetValue("SubmitSceneBox")

    # Check if Mistika VR render file exists.
    for sceneFile in sceneFiles:
        if not os.path.isfile(sceneFile):
            errors.append("Mistika VR render file: %s does not exist." %
                          sceneFile)
        elif not submitScene and PathUtils.IsPathLocal(sceneFile):
            warnings.append(
                "The Mistika VR render file: " + sceneFile +
                " is local and is not being submitted with the job, are you sure you want to continue?"
            )

    # Check if a valid frame range has been specified.
    frames = scriptDialog.GetValue("FramesBox")
    if not FrameUtils.FrameRangeValid(frames):
        errors.append("Frame range %s is not valid." % frames)

    if len(errors) > 0:
        scriptDialog.ShowMessageBox(
            "The following errors were encountered:\n\n%s\n\nPlease resolve these issues and submit again.\n"
            % ("\n\n".join(errors)), "Errors")
        return

    if len(warnings) > 0:
        result = scriptDialog.ShowMessageBox(
            "Warnings:\n\n%s\n\nDo you still want to continue?" %
            ("\n\n".join(warnings)), "Warnings", ("Yes", "No"))
        if result == "No":
            return

    jobOptions = jobOptionsDialog.GetJobOptionsValues()

    successes = 0
    failures = 0

    # Submit each Mistika VR render file separately.
    for sceneFile in sceneFiles:
        originalJobName = jobOptions["Name"]
        if len(sceneFiles) > 1:
            newJobName = "%s [%s]" % (originalJobName,
                                      os.path.basename(sceneFile))
            jobOptions["Name"] = newJobName

        # Create job info file.
        jobInfoFilename = os.path.join(ClientUtils.GetDeadlineTempPath(),
                                       "mistikavr_job_info.job")
        writer = StreamWriter(jobInfoFilename, False, Encoding.Unicode)
        writer.WriteLine("Plugin=MistikaVR")

        for option, value in jobOptions.iteritems():
            writer.WriteLine("%s=%s" % (option, value))

        writer.WriteLine("Frames=%s" % frames)
        writer.WriteLine("ChunkSize=%s" %
                         scriptDialog.GetValue("ChunkSizeBox"))

        if not submittedFromMonitor and sceneFile == rndFileName:
            writer.WriteLine("OutputFilename0=%s" %
                             outputFile.replace("%06d", "######"))

        writer.Close()

        if len(sceneFiles) > 1:
            # reset the job name for the next job to be submitted
            jobOptions["Name"] = originalJobName

        # Create plugin info file.
        pluginInfoFilename = os.path.join(ClientUtils.GetDeadlineTempPath(),
                                          "mistikavr_plugin_info.job")
        writer = StreamWriter(pluginInfoFilename, False, Encoding.Unicode)

        if not submitScene:
            writer.WriteLine("SceneFile=%s" % sceneFile)

        writer.WriteLine("ImageRender=%s" % scriptDialog.GetValue("ImageBox"))
        writer.Close()

        # Setup the command line arguments.
        arguments = [jobInfoFilename, pluginInfoFilename]

        if submitScene:
            arguments.append(sceneFile)

        if len(sceneFiles) == 1:
            results = ClientUtils.ExecuteCommandAndGetOutput(arguments)
            scriptDialog.ShowMessageBox(results, "Submission Results")
        else:
            # Now submit the job.
            exitCode = ClientUtils.ExecuteCommand(arguments)
            if exitCode == 0:
                successes = successes + 1
            else:
                failures = failures + 1

    if len(sceneFiles) > 1:
        scriptDialog.ShowMessageBox(
            "Jobs submitted successfully: %d\nJobs not submitted: %d" %
            (successes, failures), "Submission Results")
Exemplo n.º 7
0
def SubmitButtonPressed(*args):
    global scriptDialog
    global integration_dialog
    
    submitScene = bool(scriptDialog.GetValue("SubmitSceneBox"))
    multiMachine = bool(scriptDialog.GetValue("MultiMachineBox"))
    
    # Check if scene file exists
    sceneFile = scriptDialog.GetValue( "SceneBox" )
    if( not File.Exists( sceneFile ) ):
        scriptDialog.ShowMessageBox("Project file %s does not exist." % sceneFile, "Error" )
        return
    elif(not submitScene and PathUtils.IsPathLocal(sceneFile)):
        result = scriptDialog.ShowMessageBox("The project file " + sceneFile + " is local, are you sure you want to continue?","Warning", ("Yes","No") )
        if( result == "No" ):
            return
    
    concurrentTasks = scriptDialog.GetValue( "ConcurrentTasksBox" )
    if concurrentTasks > 1:
        result = scriptDialog.ShowMessageBox("The concurrent tasks is set to a value greater than 1.  This can cause Jobs to hang when rendering, are you sure you want to continue?","Warning", ("Yes","No") )
        if( result == "No" ):
            return
    
    outputFile = ""
    frames = ""
    jobName = scriptDialog.GetValue( "NameBox" )
    
    # Get the comp
    comp = scriptDialog.GetValue("CompBox")
    if comp != "":
        # Check that the output is valid
        outputFile = scriptDialog.GetValue( "OutputBox" ).strip()
        if len(outputFile) > 0:
            if not Directory.Exists( Path.GetDirectoryName(outputFile) ):
                scriptDialog.ShowMessageBox( "The directory of the output file does not exist:\n" + Path.GetDirectoryName(outputFile), "Error" )
                return
            elif(PathUtils.IsPathLocal(outputFile)):
                result = scriptDialog.ShowMessageBox("The output file " + outputFile + " is local, are you sure you want to continue?","Warning", ("Yes","No") )
                if( result == "No" ):
                    return
            
            extension = Path.GetExtension( outputFile )
            if not IsMovieFormat( extension ):
                if outputFile.find( "[#" ) < 0 and outputFile.find( "#]" ) < 0:
                    directory = Path.GetDirectoryName( outputFile )
                    filename = Path.GetFileNameWithoutExtension( outputFile )
                    outputFile = Path.Combine( directory, filename + "[#####]" + extension )
        
        #Since we don't specify ranges for multi-machine rendering, don't check frame range when Multi-Machine Rendering = True
        if not multiMachine:
            # Check if a valid frame range has been specified.
            frames = scriptDialog.GetValue( "FramesBox" )
            if( not FrameUtils.FrameRangeValid( frames ) ):
                scriptDialog.ShowMessageBox( "Frame range %s is not valid" % frames, "Error" )
                return
    else:
        jobName = jobName + " - Entire Render Queue"
    
    if multiMachine:
        jobName = jobName + " (multi-machine rendering)"
    
    # Check if Integration options are valid
    if not integration_dialog.CheckIntegrationSanity( outputFile ):
        return
    
    # Create job info file.
    jobInfoFilename = Path.Combine( ClientUtils.GetDeadlineTempPath(), "ae_job_info.job" )
    writer = StreamWriter( jobInfoFilename, False, Encoding.Unicode )
    writer.WriteLine( "Plugin=AfterEffects" )
    writer.WriteLine( "Name=%s" % jobName )
    writer.WriteLine( "Comment=%s" % scriptDialog.GetValue( "CommentBox" ) )
    writer.WriteLine( "Department=%s" % scriptDialog.GetValue( "DepartmentBox" ) )
    writer.WriteLine( "Pool=%s" % scriptDialog.GetValue( "PoolBox" ) )
    writer.WriteLine( "SecondaryPool=%s" % scriptDialog.GetValue( "SecondaryPoolBox" ) )
    writer.WriteLine( "Group=%s" % scriptDialog.GetValue( "GroupBox" ) )
    writer.WriteLine( "Priority=%s" % scriptDialog.GetValue( "PriorityBox" ) )
    writer.WriteLine( "TaskTimeoutMinutes=%s" % scriptDialog.GetValue( "TaskTimeoutBox" ) )
    writer.WriteLine( "EnableAutoTimeout=%s" % scriptDialog.GetValue( "AutoTimeoutBox" ) )
    writer.WriteLine( "ConcurrentTasks=%s" % concurrentTasks )
    writer.WriteLine( "LimitConcurrentTasksToNumberOfCpus=%s" % scriptDialog.GetValue( "LimitConcurrentTasksBox" ) )
    
    if( bool(scriptDialog.GetValue( "IsBlacklistBox" )) ):
        writer.WriteLine( "Blacklist=%s" % scriptDialog.GetValue( "MachineListBox" ) )
    else:
        writer.WriteLine( "Whitelist=%s" % scriptDialog.GetValue( "MachineListBox" ) )
    
    writer.WriteLine( "LimitGroups=%s" % scriptDialog.GetValue( "LimitGroupBox" ) )
    writer.WriteLine( "JobDependencies=%s" % scriptDialog.GetValue( "DependencyBox" ) )
    writer.WriteLine( "OnJobComplete=%s" % scriptDialog.GetValue( "OnJobCompleteBox" ) )
    
    if( bool(scriptDialog.GetValue( "SubmitSuspendedBox" )) ):
        writer.WriteLine( "InitialStatus=Suspended" )
    
    if multiMachine:
        writer.WriteLine( "MachineLimit=0" )
        writer.WriteLine( "Frames=1-%s" % scriptDialog.GetValue( "MultiMachineTasksBox" ) )
        writer.WriteLine( "ChunkSize=1" )
    else:
        if comp != "":
            writer.WriteLine( "MachineLimit=%s" % scriptDialog.GetValue( "MachineLimitBox" ) )
            writer.WriteLine( "Frames=%s" % frames )
            writer.WriteLine( "ChunkSize=%s" % scriptDialog.GetValue( "ChunkSizeBox" ) )
        else:
            writer.WriteLine( "MachineLimit=1" )
            writer.WriteLine( "Frames=0" )
            writer.WriteLine( "ChunkSize=1" )
    
    if len(outputFile) > 0:
        writer.WriteLine( "OutputFilename0=%s" % outputFile.replace( "[#####]", "#####" ) )
    
    extraKVPIndex = 0
    groupBatch = False
    if integration_dialog.IntegrationProcessingRequested():
        extraKVPIndex = integration_dialog.WriteIntegrationInfo( writer, extraKVPIndex )
        groupBatch = groupBatch or integration_dialog.IntegrationGroupBatchRequested()
        
    if groupBatch:
        writer.WriteLine( "BatchName=%s\n" % ( jobName ) ) 
    writer.Close()
    # Create plugin info file.
    version = GetVersionNumber()
    
    pluginInfoFilename = Path.Combine( ClientUtils.GetDeadlineTempPath(), "ae_plugin_info.job" )
    writer = StreamWriter( pluginInfoFilename, False, Encoding.Unicode )
    
    if(not bool(scriptDialog.GetValue("SubmitSceneBox"))):
        writer.WriteLine("SceneFile=%s" % scriptDialog.GetValue("SceneBox").replace("\\","/").strip())
        
    writer.WriteLine("Comp=%s" % scriptDialog.GetValue("CompBox"))
    writer.WriteLine("Version=%s" % str(version) )
    writer.WriteLine("IgnoreMissingLayerDependenciesErrors=%s" % scriptDialog.GetValue("MissingLayers"))
    writer.WriteLine("IgnoreMissingEffectReferencesErrors=%s" % scriptDialog.GetValue("MissingEffects"))
    writer.WriteLine("FailOnWarnings=%s" % scriptDialog.GetValue("FailOnWarnings"))
    
    if multiMachine:
        writer.WriteLine("MultiMachineMode=True")
    else:
        writer.WriteLine("LocalRendering=%s" % scriptDialog.GetValue("LocalRendering"))
    
    writer.WriteLine("OverrideFailOnExistingAEProcess=%s" % scriptDialog.GetValue("OverrideFailOnExistingAEProcess"))
    writer.WriteLine("FailOnExistingAEProcess=%s" % scriptDialog.GetValue("OverrideFailOnExistingAEProcess"))

    writer.WriteLine("MemoryManagement=%s" % scriptDialog.GetValue("MemoryManagement"))
    writer.WriteLine("ImageCachePercentage=%s" % scriptDialog.GetValue("ImageCachePercentage"))
    writer.WriteLine("MaxMemoryPercentage=%s" % scriptDialog.GetValue("MaxMemoryPercentage"))
    
    writer.WriteLine("MultiProcess=%s" % scriptDialog.GetValue("MultiProcess"))
    if version > 8:
        writer.WriteLine("ContinueOnMissingFootage=%s" % scriptDialog.GetValue("MissingFootage"))
    
    if len(outputFile) > 0:
        writer.WriteLine("Output=%s" % outputFile)
    
    writer.Close()
    
    # Setup the command line arguments.
    arguments = [ jobInfoFilename, pluginInfoFilename ]
    if scriptDialog.GetValue( "SubmitSceneBox" ):
        arguments.append( sceneFile )
    
    # Now submit the job.
    results = ClientUtils.ExecuteCommandAndGetOutput( arguments )
    scriptDialog.ShowMessageBox( results, "Submission Results" )