in scripts/ebcli_installer.py [0:0]
def _announce_success(virtualenv_location, hide_export_recommendation):
"""
Function checks whether the installation location is already in PATH.
If the location is not in PATH, the user is recommended that the location
be added to PATH along with the precise commands and instructions to do so.
The commands are specific to OS + shell combinations:
1. Windows + PowerShell: execute a visual basic script to amend PATH
2. Windows + CMD Prompt: execute a BAT script to invoke the above visual
basic script
3. UNIX + Bash: echo PATH modifier to .bash_profile and source it
4. UNIX + Zsh: echo PATH modifier to .zshenv and source it
On Windows, users will be expected to run either a visual basic script
(if using PowerShell) or a Batch script (which wraps the above visual basic
script) to amend their PATH variable. This function also generates these
scripts but only when `virtualenv_location` is not already in PATH.
:param virtualenv_location: the relative or absolute path to the location
where the virtualenv, ".ebcli-virtual-env", was
created.
:param hide_export_recommendation: boolean indicating whether or not to
hide PATH export instructions. Useful
when invoked from shells that allow
modifying system PATH variable
conveniently.
:return: None
"""
new_location = _eb_wrapper_location(virtualenv_location)
if new_location in os.environ['PATH']:
content = MINIMAL_INSTALLATION_SUCCESS_MESSAGE.format(
path=new_location,
new_eb_path=os.path.join(new_location, 'eb')
)
_print_success_message(content)
else:
path_exporter = os.path.join(new_location, 'path_exporter.vbs')
path_exporter_wrapper = os.path.join(new_location, 'path_exporter.bat')
if sys.platform.startswith('win32'):
with open(path_exporter, 'w') as file:
file.write(
PATH_EXPORTER_SCRIPTS['vbs'].format(
new_location=new_location
)
)
with open(path_exporter_wrapper, 'w') as file:
file.write(
PATH_EXPORTER_SCRIPTS['bat'].format(
path_exporter_script=path_exporter
)
)
_print_success_message('Success!')
if not hide_export_recommendation:
_print_recommendation_message(
INSTALLATION_SUCCESS_MESSAGE_WITH_EXPORT_RECOMMENDATION__WINDOWS
.format(
path_exporter_bat=path_exporter_wrapper,
path_exporter=path_exporter
)
)
else:
_print_success_message('Success!')
_print_recommendation_message(
INSTALLATION_SUCCESS_MESSAGE_WITH_EXPORT_RECOMMENDATION__NON_WINDOWS
.format(eb_location=new_location)
)