def activate(dirname, ui_mode, conda_environment, command_name):
"""Prepare project and return lines to be sourced.
Future direction: should also activate the proper conda env.
Returns:
None on failure or a list of lines to print.
"""
project = load_project(dirname)
result = prepare_with_ui_mode_printing_errors(project,
ui_mode=ui_mode,
env_spec_name=conda_environment,
command_name=command_name)
if result.failed:
return None
exports = []
# sort so we have deterministic output order for tests
sorted_keys = list(result.environ.keys())
sorted_keys.sort()
for key in sorted_keys:
value = result.environ[key]
if key not in os.environ or os.environ[key] != value:
exports.append("export {key}={value}".format(key=key, value=quote(value)))
return exports
评论列表
文章目录