/** * Update the dialog contents. * * @param jheader The job portion of the dialog header. * @param job The queue job. * @param info The current job status information. */ public void updateContents( String jheader, QueueJob job, QueueJobInfo info, SubProcessExecDetails details) { ActionAgenda agenda = job.getActionAgenda(); QueueJobResults results = info.getResults(); String dir = "-"; if ((agenda != null) && (info.getOsType() != null)) dir = agenda.getTargetPath(info.getOsType()).toString(); String hostname = ""; if (info.getHostname() != null) hostname = (" [" + info.getHostname() + "]"); String command = "-"; if (details != null) command = details.getCommand(); TreeMap<String, String> env = new TreeMap<String, String>(); if (details != null) env = details.getEnvironment(); setHeader("Execution Details -" + jheader + hostname); pWorkingDirField.setText(dir); BaseAction action = job.getAction(); pCommandLineLabel.setText( "Action Command: " + action.getName() + " (v" + action.getVersionID() + ")"); pCommandLineArea.setText(command); { Component comps[] = UIFactory.createTitledPanels(); { JPanel tpanel = (JPanel) comps[0]; JPanel vpanel = (JPanel) comps[1]; if (!env.isEmpty()) { String last = env.lastKey(); for (String key : env.keySet()) { String value = env.get(key); JTextField field = UIFactory.createTitledTextField(tpanel, key + ":", sTSize, vpanel, value, sVSize); field.setHorizontalAlignment(JLabel.LEFT); if (!key.equals(last)) UIFactory.addVerticalSpacer(tpanel, vpanel, 3); } } else { tpanel.add(Box.createRigidArea(new Dimension(sTSize, 0))); vpanel.add(Box.createHorizontalGlue()); } } pEnvLabel.setText("Toolset Environment: " + agenda.getToolset()); pEnvScroll.setViewportView(comps[2]); } }
/** * Updates the asset references for a shot within Maya and then in pipeline. * * @param shotName The name of the shot being processed. * @param pRemoveRef The list of assets being dereferenced from the shot. * @param pReplaceRef The list of assets being referenced into the shot. * @param nameMap */ private void editShotReferences( String shotName, NodeMod targetMod, TreeSet<String> pRemoveRef, TreeSet<String> pReplaceRef, TreeMap<String, String> nameMap) throws PipelineException { logLine("Editing shot: " + shotName); boolean anim = !shotName.matches(lgtPattern); /* writing the mel script */ if (anim) { File script = null; try { script = File.createTempFile("UpdateAssetGUI.", ".mel", PackageInfo.sTempPath.toFile()); FileCleaner.add(script); } // end try catch (IOException ex) { throw new PipelineException( "Unable to create the temporary MEL script used to collect " + "texture information from the Maya scene!"); } // end catch try { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(script))); for (String asset : pReplaceRef) { String nameSpace; if (asset.endsWith(lr)) nameSpace = nameMap.get(getShortName(asset.substring(0, asset.length() - 3))); else { System.err.println("This should not be happening, a hi res asset in a lo-res node."); continue; // nameSpace = nameMap.get(getShortName(asset)); } out.println("print (\"referencing file: $WORKING" + asset + ".ma\");"); out.println( "file -reference -namespace \"" + nameSpace + "\" \"$WORKING" + asset + ".ma\";"); } // end for for (String asset : pRemoveRef) { out.println("print (\"dereferencing file: $WORKING" + asset + ".ma\");"); out.println("file -rr \"$WORKING" + asset + ".ma\";"); } // end for out.println("// SAVE"); out.println("file -save;"); out.close(); } // end try catch (IOException ex) { throw new PipelineException( "Unable to write the temporary MEL script(" + script + ") used add the references!"); } // end catch NodeID targetID = new NodeID(w.user, w.view, shotName); // NodeStatus targetStat = mclient.status(targetID); /* run Maya to collect the information */ try { Path targetPath = getNodePath(shotName); ArrayList<String> args = new ArrayList<String>(); args.add("-batch"); args.add("-script"); args.add(script.getPath()); args.add("-file"); args.add(targetPath.toOsString()); Path wdir = new Path(PackageInfo.sProdPath.toOsString() + targetID.getWorkingParent()); TreeMap<String, String> env = mclient.getToolsetEnvironment( w.user, w.view, targetMod.getToolset(), PackageInfo.sOsType); Map<String, String> nenv = env; String midefs = env.get("PIPELINE_MI_SHADER_PATH"); if (midefs != null) { nenv = new TreeMap<String, String>(env); Path dpath = new Path(new Path(wdir, midefs)); nenv.put("MI_CUSTOM_SHADER_PATH", dpath.toOsString()); } String command = "maya"; if (PackageInfo.sOsType.equals(OsType.Windows)) command += ".exe"; SubProcessLight proc = new SubProcessLight("UpdateAssetGUI", command, args, env, wdir.toFile()); try { proc.start(); proc.join(); if (!proc.wasSuccessful()) { throw new PipelineException( "Did not correctly edit the reference due to a maya error.!\n\n" + proc.getStdOut() + "\n\n" + proc.getStdErr()); } // end if } // end try catch (InterruptedException ex) { throw new PipelineException(ex); } // end catch } // end try catch (Exception ex) { throw new PipelineException(ex); } // end catch } /*-edit the references in pipeline once they are done in the file-*/ BaseAction targetAction = targetMod.getAction(); for (String asset : pReplaceRef) { mclient.link( w.user, w.view, shotName, asset, LinkPolicy.Reference, LinkRelationship.All, null); if (anim) { /*Set the namespaces*/ String nameSpace = nameMap.get(getShortName(asset.substring(0, asset.length() - 3))); System.err.println(nameSpace); targetAction.initSourceParams(asset); targetAction.setSourceParamValue(asset, "PrefixName", nameSpace); targetMod.setAction(targetAction); } } w.mclient.modifyProperties(w.user, w.view, targetMod); for (String asset : pRemoveRef) mclient.unlink(w.user, w.view, shotName, asset); if (!anim) { System.err.println("Queuing the switchLgt node " + shotName); mclient.submitJobs(w.user, w.view, shotName, null); } } // end editShotReferences