def getEnv (): env_data = "source $HOME/.bashrc\n" env_data += "source $HK_ROOT/users/$USER/.hk/$HK_PROJECT\n\n" env_data += "#Set environment variables\n" env_data += "export HK_DB=$HK_PROJECT\n" env_data += "export HK_COAT_VER=4-0-03\n" env_data += "export HK_COAT_VER_T=4-0-03\n" env_data += "export HK_GUERILLA_VER=0.17.0b12\n" env_data += "export HK_GUERILLA_VER_T=0.17.0b12\n" env_data += "export HK_HIERO_VER=1.6v1\n" env_data += "export HK_HIERO_PLAYER_VER=1.6v1\n" env_data += "export HK_HOUDINI_VER=12.5\n" env_data += "export HK_MARI_VER=2.0v1\n" env_data += "export HK_MARI_VER_T=2.1v1a1\n" env_data += "export HK_MAYA_ROOT=/usr/autodesk\n" env_data += "export HK_MAYA_VER=2013\n" env_data += "export HK_MODO_VER=701\n" env_data += "export HK_MUDBOX_VER=2013\n" env_data += "export HK_NUKE_VER=7.0v2\n" env_data += "export HK_BADASS_VER=%s\n\n" % utils.getBadassVersion () env_data += "if $HK_DEV_MODE\n" env_data += " then\n" env_data += " hkmode=\"dev\"\n" env_data += "fi\n\n" env_data += "alias work='cd $HK_HOME'\n\n" env_data += "logpath=\"$HK_USER_REPO\"\n" env_data += "export HK_BADASS=\"$HK_CODE_PATH/python/assetmanager/$HK_BADASS_VER\"\n" env_data += "export HK_COUCHDB=\"$HK_CODE_PATH/python/couchdb-python\"\n" env_data += "export HK_PYSIDE=\"$HK_CODE_PATH/python/pyside\"\n" env_data += "argparse=\"$HK_CODE_PATH/python/argparse\"\n" env_data += "json=\"$HK_CODE_PATH/python/json\"\n" env_data += "export PYTHONPATH=\"$HK_BADASS:$json:$argparse:$PYTHONPATH\"\n\n" env_data += "#Set PS1\n" env_data += r"export PS1='\[\033[1;34m\]|\u@\h\[\033[1;37m\]|\t\[\033[1;31m\]|$HK_PROJECT|$hkmode>\[\033[0;33m\]\w$ \[\033[00m\]'" + "\n\n" env_data += "#Set the current directory\n" env_data += "if ! ([ -d $logpath ])\n" env_data += " then\n" env_data += " mkdir -p $logpath\n" env_data += "fi\n" return env_data
def createProjectEnv (name = "", badassversion = None): """ This function create a project environment file. It contains project environment variables related to the project. This file is sourced each times a user log to a project via the hk-project command. :param name: The project name. :type name: str :param badassVersion: The asset manager version. :type badassVersion: str :returns: str/bool -- If environment file created return the file path else False **Example:** >>> createProjectEnv ( name = "prod" ) >>> '/homeworks/projects/prod/config/prod.env' """ # Check the project name is if (name!=None) and (name==""): return False if not badassversion: badassversion=utils.getBadassVersion() # TODO:Create this document with a ui env_data="source $HOME/.bashrc\n" env_data+="source $HK_ROOT/users/$USER/.hk/$HK_PROJECT\n\n" env_data+="#Set environment variables\n" env_data+="export HK_DB=$HK_PROJECT\n" env_data+="export HK_COAT_VER=4-0-03\n" env_data+="export HK_COAT_VER_T=4-0-03\n" env_data+="export HK_GUERILLA_VER=0.17.0b12\n" env_data+="export HK_GUERILLA_VER_T=0.17.0b12\n" env_data+="export HK_HIERO_VER=1.6v1\n" env_data+="export HK_HIERO_PLAYER_VER=1.6v1\n" env_data+="export HK_HOUDINI_VER=12.5\n" env_data+="export HK_MARI_VER=2.0v1\n" env_data+="export HK_MARI_VER_T=2.1v1a1\n" env_data+="export HK_MAYA_ROOT=/usr/autodesk\n" env_data+="export HK_MAYA_VER=2013\n" env_data+="export HK_MODO_VER=701\n" env_data+="export HK_MUDBOX_VER=2013\n" env_data+="export HK_NUKE_VER=7.0v2\n" env_data+="export HK_BADASS_VER=%s\n\n"%badassversion env_data+="if $HK_DEV_MODE\n" env_data+=" then\n" env_data+=" hkmode=\"|dev\"\n" env_data+="fi\n\n" env_data+="alias work='cd $HK_HOME'\n\n" env_data+="logpath=\"$HK_USER_REPO\"\n" env_data+="export HK_BADASS=\"$HK_CODE_PATH/python/asset-manager/$HK_BADASS_VER\"\n" env_data+="export HK_COUCHDB=\"$HK_CODE_PATH/python/couchdb-python\"\n" env_data+="export HK_PYSIDE=\"$HK_CODE_PATH/python/pyside\"\n" env_data+="argparse=\"$HK_CODE_PATH/python/argparse\"\n" env_data+="json=\"$HK_CODE_PATH/python/json\"\n" env_data+="export PYTHONPATH=\"$HK_BADASS:$json:$argparse:$PYTHONPATH\"\n\n" env_data+="#Set PS1\n" env_data+=r"export PS1='\[\033[1;34m\]|\u@\h\[\033[1;37m\]|\t\[\033[1;31m\]|$HK_PROJECT$hkmode>\[\033[0;33m\]\w$ \[\033[00m\]'"+"\n\n" env_data+="#Set the current directory\n" env_data+="if ! ([ -d $logpath ])\n" env_data+=" then\n" env_data+=" mkdir -p $logpath\n" env_data+="fi\n" # Get the project env file env_file=utils.getProjectEnv (name) if env_file : # Create Environment file if utils.createFile (env_file, env_data): print "createProjectEnv(): %s created "%env_file return env_file else: print "createProjectEnv(): can't create %s "%env_file return False else: print "createProjectEnv(): can't get project env %s "%env_file return False