Author Topic: whitespace removal - where to do it?  (Read 8208 times)

pinkwerks

  • Sr. Member
  • ****
  • Posts: 26
    • Method Studios
whitespace removal - where to do it?
« on: February 24, 2009, 08:40:10 PM »
We have artists screw up render submits from the GUI using simple commands because of white space " before" quoted command arguments when cutting and pasting.  If It'd be nice if the simple command scripts chopped off any leading white space. In my case, I'd like to ensure that the 'scenefile' of the 'Maya BatchRender (mr)' jobtype did this.

So looking at this briefly, what file would be the best one to put a bit of logic in for this sort of thing? 

siyuan.pipelinefx

  • Sr. Member
  • ****
  • Posts: 32
Re: whitespace removal - where to do it?
« Reply #1 on: February 26, 2009, 05:44:14 AM »
I'll need to consult with our software engineers for this.  I'll keep you posted.

Scot Brew

  • Hero Member
  • *****
  • Posts: 272
    • PipelineFX
Re: whitespace removal - where to do it?
« Reply #2 on: February 27, 2009, 02:00:21 AM »
The postDialog callback can be used to clean up and modify any parameters set in the submission dialog.  This can be used to perform path translation along with the removal of whitespace.  Using the strip() string operation will clear out leading and trailing whitespace for the values.

The code below is derived from the code used on the path translation post for the maya batchrender jobtype:

Code: [Select]
def postDialog(cmd, jobProps):
    # Get a list of properties that use paths
    fileProps = set([k for k,v in cmd.options.iteritems() if v.get('type', '') in ['dir', 'file']])
    # For path properties, strip leading and trailing whitespace
    for k,v in jobProps.setdefault('package', {}).iteritems():
        if k in fileProps:
            jobProps['package'][k] = v.strip()
            logging.info('Adjusted path for property "%s" to "%s"'%(k,jobProps['package'][k]))
           
           
If modifying the mayabatch jobtype, the postDialog callback is specified here:
Code: [Select]
def create_generalMayaRenderer(rendererShortname, rendererFullname, helpStdout, installFunc=None):
    cmdjob = SimpleCmd('Maya BatchRender (%s)'%rendererShortname, hasRange=True, canChunk=True, help='maya batch render using %s renderer options from Maya 2008'%rendererFullname, postDialog=postDialog)

See the following link for reference:
   http://support.pipelinefx.com/smf/index.php?topic=564.msg1408#msg1408