10 examples of 'os.environ.get' in Python

Every line of 'os.environ.get' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
37def get_user_environment():
38 new_env = os.environ.copy()
39 if 'SUDO_USER' in new_env:
40 new_env['HOME'] = os.path.expanduser('~' + new_env['SUDO_USER'])
41 new_env['USER'] = new_env['SUDO_USER']
42 new_env['USERNAME'] = new_env['SUDO_USER']
43
44 return new_env
15def env_default(key):
16 """Return environment variable or placeholder string.
17
18 Set environment variable to placeholder if it doesn't exist.
19 """
20 test_environ = 'prawtest_{}'.format(key)
21 test_value = os.environ.get(test_environ, 'placeholder_{}'.format(key))
22 return os.environ.setdefault('praw_{}'.format(key), test_value)
31def get_env(default: Optional[str] = "production") -> str:
32 """Reads QUART_ENV environment variable to determine in which environment
33 the app is running on. Defaults to 'production' when unset.
34 """
35 return os.getenv("QUART_ENV", default)
15def _getenv(env, default=None):
16 """If ENV doesn't exist or None, return default value."""
17 # Note that os.getenv('') always returns None
18 return os.getenv(_env(env), default)
11def build_env():
12 args = []
13 # Android linker ignores RPATH. Set LD_LIBRARY_PATH to Output dir.
14 args.append('LD_LIBRARY_PATH=%s:%s' %
15 (ANDROID_TMPDIR, os.environ.get('LD_LIBRARY_PATH', '')))
16 for (key, value) in os.environ.items():
17 if key in ['ASAN_OPTIONS']:
18 args.append('%s="%s"' % (key, value))
19 return ' '.join(args)
147def setEnviron():
148 """ Setup the environment variables needed to import localrec classes. """
149 os.environ.update(getRelionEnviron())
150 sys.path.append(os.path.join(os.environ[LOCALREC_HOME], "lib"))
135def get_envname():
136 return {
137 'bench-odroid-1': 'ccl-bench-odroid-1',
138 'bench-raspi-1': 'ccl-bench-raspi-1',
139 'bench-hdd-1': 'ccl-bench-hdd-1',
140 'bench-ssd-1': 'ccl-bench-ssd-1',
141 'bench-ssd-6': 'ccl-bench-ssd-6',
142 }.get(HOSTNAME, '')
4def get_env(key):
5 val = os.getenv(key.upper())
6 if val:
7 return val
8 raise ValueError(f"{key} is not defined")
21def get_env(key: str) -> str:
22 if key in os.environ:
23 return os.environ[key]
24 return ""
287def getenv(name, default='', m={}):
288 return env(m).get(name, default)

Related snippets