tractor emtpy string argument issues

   2397   1   0
User Avatar
Member
1736 posts
Joined: May 2006
Online
Thought I'd write it up here again for completeness, in case there's other tractor folk who could help out!

pdg is generating a command line for tractor with lots of switch+value pairs. One of those is -to with an empty string:

blah_blah -to '' -i 'ropfetch1_139' -s '172.1.2.2:1234

When this is passed to the tractor api, it converts this to json:

RemoteCmd blah_blah {-to} {} {-i} {ropfetch1_139} {-s} {172.1.2.2:1234}

The empty curly braces get eaten somewhere, so the command is now broken:

RemoteCmd blah_blah {-to} {-i} {ropfetch1_139} {-s} {172.1.2.2:1234}

As someone else pointed out it should be fixed by explicitly converting the empty string to double quotes wrapped in single quotes, which involved usual fun python tricks of escaping single and double quotes. I thought this cunning attempt of wrapping what I need ( ‘“”’ ) in triple quotes would solve it. This is in HFS/houdini/pdg/types/schedulers/prtractor.py, around line 555, just before the argument list is converted to a tractor task):

cmd_argv = ["""'""'""" if x is '' else x for x in cmd_argv]

But no, tractor still gets confused.

In an effort to reliably remove the -to '' argument pair if it has an empty string, but leave it alone otherwise, I kludged this awful thing to zip the argument list into pairs, check if the second element of the pair is empty, then flatten the list again after removing redundant commands:

c = cmd_argv
# pair up
c2 = [ (c[i*2],c[i*2+1]) for i in range(len(c)/2)]
# remove if second argument is empty
c3 = [x for x in c2 if x[1] is not '']
# flatten list again
cmd_argv = [item for sublist in c3 for item in sublist]

Seems to work, but now I get the socket error mentioned in another post.

Cheers,

-matt
Edited by mestela - March 25, 2019 20:06:11
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Staff
585 posts
Joined: May 2014
Offline
I've fixed the ROP Fetch node so that it doesn't pass that argument when the value is empty string, which should fix this specific case. We'll be applying a fix for the Tractor Scheduler itself as well, but tomorrows build will definitely have the ROP-specific fix.
Edited by tpetrick - March 26, 2019 14:20:02
  • Quick Links