Example #1
0
    def on_done(self, shelfToolName):

        ### Update config with new tool name
        configAll = subPorts.getConfig()
        configAll['shelftool'] = shelfToolName
        # print(configAll)

        plugin_path = '%s/SubTunnel' % (sublime.packages_path())
        config = '%s/config.json' % plugin_path
        f = open(config, 'w')
        f.write(json.dumps(configAll))
        f.close()

        ### Send the code
        port = subPorts.getPort()
        h = Tunnel(self.window,port) 

        code = h.codeAsText
        python = "hou.shelves.tools()['%s'].setData('%s')" % (shelfToolName,code)
        hscriptCmd = r'''python -c \"%s\"''' % python
        

        cmd = r'''%s "%s"''' % (h.hcommand,hscriptCmd)

        print ("CMD shelf:", cmd)
        p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
        cmd_stdout, cmd_stderr = p.communicate()  
Example #2
0
    def run(self):

        port = subPorts.getPort()

        h = Tunnel(self.window,port)   

        # print (h.nodeType)
        # print (h.nodePath)
        # print (h.filePath)             # path to the temporary code file
        # print (h.getCodeAsText)
        # print ('HIP',h.hipfile)
        
        if h.nodeType in ['attribwrangle', 'pointwrangle', 'volumewrangle', 'popwrangle']:  # VEX WRANGLE nodes


            hscriptCmd = r'''opparm %s snippet \"%s\"''' % (h.nodePath,h.codeAsText) # Hscript command + \"  around already escaped code
            # hscriptCmd = subPorts.escape(hscriptCmd, 1)                            # No espcing here - the code already is escaped
            cmd = r'''%s "%s"''' % (h.hcommand,hscriptCmd)

            # cmd = ''' %s  \"opparm %s snippet \\"%s\\" \"''' %(h.hcommand, h.nodePath,h.codeAsText)    

            print ("CMD - vexsop", cmd)
            p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
            cmd_stdout, cmd_stderr = p.communicate()   

        elif h.nodeType in ['inline']:                       # INLINE VEX VOPSOP - same as wrangle nodes but with different param name
            # cmd = ''' %s  \"opparm %s code \\"%s\\" \"''' %(h.hcommand, h.nodePath,h.codeAsText)    
            
            hscriptCmd = r'''opparm %s code \"%s\"''' % (h.nodePath,h.codeAsText)  # just and escape around codeAsText                         
            cmd = r'''%s "%s"''' % (h.hcommand,hscriptCmd)

            print ("CMD inline", cmd)
            p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
            cmd_stdout, cmd_stderr = p.communicate()   

        elif h.nodeType == "python":                        # PYTHON SOP
            # cmd = ''' %s  \"opparm %s python \\"%s\\" \"''' %(h.hcommand, h.nodePath,h.codeAsText)    # 2x backslash to have \" in terminal

            hscriptCmd = r'''opparm %s python \"%s\"''' % (h.nodePath,h.codeAsText)  # just and escape around codeAsText                          
            cmd = r'''%s "%s"''' % (h.hcommand,hscriptCmd)
            print ("CMD python sop", cmd)
 
            p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
            cmd_stdout, cmd_stderr = p.communicate()     
        
        elif h.nodeType=="":                                # In case no node is selected
            portMesssage = '\tPort %s not opened' % h.port
            self.window.show_quick_panel(['\tNo Node selected or...', portMesssage, '\t-> run openport -a in Houdini Textport', '\t-> rerun "Tunnel Sessions" to connect to running Houdini session'], 0 ,sublime.MONOSPACE_FONT)

        else:                                                # HDA code / scripts tab
            # For hda find its type to determine what network it is suppose to go
            tableAndOpName = self.getTableAndOpName(h.hcommand,h.nodePath)

            hdaOptions = self.getHdaContent(h.hcommand,tableAndOpName)
            hdaLabels = self.getHdaContent(h.hcommand,tableAndOpName)
            print ("NTWK type: ", tableAndOpName)
            print ("HDA Options:", hdaOptions)
            info = ['','INFO:', 'File Path: {:>25s}'.format(h.hipfile), 'Node Path: {:>25s}'.format(h.nodePath), 'Node Type: {:>25s}'.format(tableAndOpName)]
            hdaLabels.extend(info)

            # TODO there is still a problem with vex otl where the
            # otcontentadd Sop/testVex VexCode /home/kuba/temp/bbbbb.vex
            # has no effect
            
            self.window.run_command('save')           # save the current sublime file
            self.window.show_quick_panel(hdaLabels, lambda id: self.hdaRun(id,hdaOptions,h,tableAndOpName) ,sublime.MONOSPACE_FONT)