Send bash environment variable back to python fabric

I am trying to pass the bash environment variable back to my fabric function as follows: -

from fabric.api import env

def env_localhost():
    "All the environment variables relating to your localhost"
    project_home = local('echo $PROJECT_HOME')
    print 111, project_home

But it does not seem to be able to get stdout results and assign it to my python variable project_home. What is the right way to do it right?

+5
source share
2 answers

Do it like this:

import os
os.getenv("PATH")
+6
source

also:

import os
os.environ['PROJECT_HOME']
+3
source

All Articles