Example #1
0
 def set_workspace(self, path):
     """
     Set the workspace
     """
     path = self.conform(path)
     os.environ["JOB"] = path
     hou.allowEnvironmentToOverwriteVariable("JOB", True)
Example #2
0
    def launchProject(self, filePath):
        tokenDict = self.get_token_dict()
        self.houdini_tools.debug_msg("Setting environment variables: ")
        for token in tokenDict:
            os.environ[token] = tokenDict[token]
            self.houdini_tools.debug_msg(token + " = " + tokenDict[token])

        self.houdini_tools.debug_msg("Here we go!")
        hou.allowEnvironmentToOverwriteVariable("JOB", True)
        hou.putenv("JOB", "COOL DUDE")
        forwardSlashPath = filePath.replace('\\', '/')
        hou.hipFile.load(forwardSlashPath)
        return True
Example #3
0
    def set_environment_variable(cls, var, value):
        """sets environment var

        :param str var: The name of the var
        :param value: The value of the variable
        """
        os.environ[var] = value
        try:
            hou.allowEnvironmentVariableToOverwriteVariable(var, True)
        except AttributeError:
            # should be Houdini 12
            hou.allowEnvironmentToOverwriteVariable(var, True)

        hscript_command = "set -g %s = '%s'" % (var, value)
        hou.hscript(str(hscript_command))
Example #4
0
    def set_environment_variable(cls, var, value):
        """sets environment var

        :param str var: The name of the var
        :param value: The value of the variable
        """
        os.environ[var] = value
        try:
            hou.allowEnvironmentVariableToOverwriteVariable(var, True)
        except AttributeError:
            # should be Houdini 12
            hou.allowEnvironmentToOverwriteVariable(var, True)

        hscript_command = "set -g %s = '%s'" % (var, value)
        hou.hscript(str(hscript_command))
Example #5
0
    def _get_graph(self, **kwargs):
        hou.allowEnvironmentToOverwriteVariable('JOB', True)
        hou.hscript('set JOB=' + os.environ.get('JOB'))

        hafarm_node = hou.pwd()
        if hafarm_node.type().name() != 'HaFarm':
            raise Exception('Please, select the HaFarm node.')

        graph = HaGraph(graph_items_args=[])
        for x in get_hafarm_list_deps(hafarm_node.path()):
            hou_node_type, index, deps, path, hafarms = x
            for item in HoudiniWrapper(hou_node_type, index, path,
                                       houdini_dependencies[index], hafarms):
                if item == None: continue
                graph.add_node(item)
                houdini_nodes[item.index] = item
        return graph
Example #6
0
def _loadHipFile(hip_file, error_logger=None):
    import hou

    # We need to switch our backslashes to forward slashes for UNC paths to
    # work correctly
    hip_file = hip_file.replace("\\", "/")

    if not os.path.exists(hip_file):
        _failWithProjectError("ERROR: Cannot find file %s" % hip_file,
                              error_logger)

    # We want to allow the JOB environment variable to override the value
    # saved in the hip file, before we load it (so that we can load otl files
    # based off $JOB).
    if hasattr(hou, "allowEnvironmentToOverwriteVariable"):
        if "JOB" in os.environ:
            hou.allowEnvironmentToOverwriteVariable("JOB", True)

    # Note that we ignore all load warnings.
    try:
        hou.hipFile.load(hip_file)
    except hou.LoadWarning:
        pass
Example #7
0
    def set_environment_variables(self, version):
        """sets the environment variables according to the given Version
        instance
        """
        if not version:
            return

        # set the $JOB variable to the parent of version.full_path
        logger.debug('version: %s' % version)
        logger.debug('version.path: %s' % version.path)
        logger.debug('version.filename: %s' % version.filename)
        logger.debug('version.full_path: %s' % version.full_path)
        logger.debug(
            'version.full_path (calculated): %s' %
            os.path.join(
                version.path,
                version.filename
            ).replace("\\", "/")
        )
        job = os.path.dirname(str(version.full_path))
        hip = job
        hipName = os.path.basename(hip)

        logger.debug('job     : %s' % job)
        logger.debug('hip     : %s' % hip)
        logger.debug('hipName : %s' % hipName)

        try:
            hou.allowEnvironmentVariableToOverwriteVariable("JOB", True)
            hou.allowEnvironmentVariableToOverwriteVariable("HIP", True)
            hou.allowEnvironmentVariableToOverwriteVariable("HIPNAME", True)
        except AttributeError:
            # should be Houdini 12
            hou.allowEnvironmentToOverwriteVariable('JOB', True)
            hou.allowEnvironmentToOverwriteVariable('HIP', True)
            hou.allowEnvironmentToOverwriteVariable('HIPNAME', True)

        # update the environment variables
        #os.environ.update({"JOB": job})
        os.environ["JOB"] = job
        os.environ["HIP"] = hip
        os.environ["HIPNAME"] = hipName

        # also set it using hscript, hou is a little bit problematic
        hou.hscript("set -g JOB = '%s'" % job)
        hou.hscript("set -g HIP = '%s'" % hip)
        hou.hscript("set -g HIPNAME = '%s'" % hipName)
Example #8
0
    def set_environment_variables(self, version):
        """sets the environment variables according to the given Version
        instance
        """
        if not version:
            return

        # set the $JOB variable to the parent of version.full_path
        logger.debug('version: %s' % version)
        logger.debug('version.path: %s' % version.path)
        logger.debug('version.filename: %s' % version.filename)
        logger.debug('version.full_path: %s' % version.full_path)
        logger.debug(
            'version.full_path (calculated): %s' %
            os.path.join(version.path, version.filename).replace("\\", "/"))
        job = os.path.dirname(str(version.full_path))
        hip = job
        hipName = os.path.basename(hip)

        logger.debug('job     : %s' % job)
        logger.debug('hip     : %s' % hip)
        logger.debug('hipName : %s' % hipName)

        try:
            hou.allowEnvironmentVariableToOverwriteVariable("JOB", True)
            hou.allowEnvironmentVariableToOverwriteVariable("HIP", True)
            hou.allowEnvironmentVariableToOverwriteVariable("HIPNAME", True)
        except AttributeError:
            # should be Houdini 12
            hou.allowEnvironmentToOverwriteVariable('JOB', True)
            hou.allowEnvironmentToOverwriteVariable('HIP', True)
            hou.allowEnvironmentToOverwriteVariable('HIPNAME', True)

        # update the environment variables
        #os.environ.update({"JOB": job})
        os.environ["JOB"] = job
        os.environ["HIP"] = hip
        os.environ["HIPNAME"] = hipName

        # also set it using hscript, hou is a little bit problematic
        hou.hscript("set -g JOB = '%s'" % job)
        hou.hscript("set -g HIP = '%s'" % hip)
        hou.hscript("set -g HIPNAME = '%s'" % hipName)
Example #9
0
ignoreInputs = options.ignore_inputs

# Loading HIP file, and force HIP variable:
force_hip = True  # not sure, we need to force HIP variable.
# May be this code is obsolete
if force_hip:
    envhip = os.path.abspath(hip)
    envhip = os.path.dirname(envhip)

    if os.name != 'nt':
        envhip = envhip.replace('\\\\', '/')  # for nt //server/share/path is
        # the only one way

    envhip = envhip.replace('\\', '/')  # houdini always use unix-like path
    os.environ['HIP'] = envhip
    hou.allowEnvironmentToOverwriteVariable('HIP', True)
    hou.hscript('set HIP=' + envhip)

# Note that we ignore all load warnings.
try:
    hou.hipFile.load(hip)
except hou.LoadWarning:
    pass
# hou.hipFile.load( hip, True)

if force_hip:
    hou.hscript('set HIPNAME=%s' % os.path.basename(hip))
    hou.hscript('set HIP=%s' % envhip)
    print('HIP set to "%s"' % envhip)

# Establish ROP to be used
Example #10
0

# Loading HIP file, and force HIP variable:
force_hip = True  # not sure, we need to force HIP variable.
# May be this code is obsolete
if force_hip:
    envhip = os.path.abspath(hip)
    envhip = os.path.dirname(envhip)

    if os.name != 'nt':
        envhip = envhip.replace('\\\\', '/')  # for nt //server/share/path is
        # the only one way

    envhip = envhip.replace('\\', '/')  # houdini always use unix-like path
    os.environ['HIP'] = envhip
    hou.allowEnvironmentToOverwriteVariable('HIP', True)
    hou.hscript('set HIP=' + envhip)

# Note that we ignore all load warnings.
try:
    hou.hipFile.load(hip)
except hou.LoadWarning:
    pass
# hou.hipFile.load( hip, True)

if force_hip:
    hou.hscript('set HIPNAME=%s' % os.path.basename(hip))
    hou.hscript('set HIP=%s' % envhip)
    print('HIP set to "%s"' % envhip)

# Establish ROP to be used
Example #11
0
        workspace_file.close
    
        #  Write out the render path :
        if renPath and os.path.isdir( renPath ) :
            try :
                nim_file=open( os.path.join( path, 'nim.mel' ), 'w' )
                nim_file.write( renPath )
                nim_file.close
            except : P.info( 'Sorry, unable to write the nim.mel file' )
    '''

    #  Set Project :
    try:
        pathToSet = path.replace('\\', '/') + '/'
        if os.path.isdir(pathToSet):
            # update the environment variables
            os.environ.update({"JOB": str(pathToSet)})
            # update JOB using hscript
            hou.hscript("set -g JOB = '" + str(pathToSet) + "'")
            hou.allowEnvironmentToOverwriteVariable("JOB", True)
            P.info('Current Project Set: %s\n' % pathToSet)
        else:
            P.info('Project not set!')
    except:
        pass

    return True


#  End