Skip to content

Commit e548ccc

Browse files
committed
Support installing EBCLI from source
This will be useful during testing specific commits/development versions of the package
1 parent 38039b8 commit e548ccc

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

scripts/ebcli_installer.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,24 @@ def _announce_success(virtualenv_location):
330330

331331

332332
def _print_in_foreground(message, color_number):
333+
"""
334+
Function prints a given `message` on the terminal in the foreground. `color_number`
335+
is a number between and including 0 and 255. FOr a list of color codes see:
336+
337+
https://misc.flogisoft.com/bash/tip_colors_and_formatting#background1
338+
339+
On Windows, `color_number` is rejected, and hence not used. At present, PowerShell
340+
is able to recognize ANSI/VT100 escape sequences, however, CMD prompt is not.
341+
342+
:param message: a string to print in the foreground on the terminal
343+
:param color_number: an integer between and including 0 and 255 representing
344+
a color
345+
:return: None
346+
"""
333347
if sys.platform.startswith('win32'):
334348
print(message)
335349
else:
350+
# Courtesy https://misc.flogisoft.com/bash/tip_colors_and_formatting
336351
print(
337352
"\033[38;5;{color_number}m{message}\033[0m".format(
338353
color_number=color_number,
@@ -468,17 +483,23 @@ def _generate_ebcli_wrappers(virtualenv_location):
468483

469484

470485
@Step('Installing EBCLI')
471-
def _install_ebcli(quiet, version):
486+
def _install_ebcli(quiet, version, ebcli_source):
472487
"""
473488
Function installs the awsebcli presumably within the virtualenv,
474489
".ebcli-virtual-env", created and activated by this script apriori.
475490
If `version` is passed, the specific version of the EBCLI is installed.
491+
492+
The presence of `version` and `ebcli_source` will lead to an exception
493+
as they represent two different ways of installing the EBCLI.
494+
476495
:param quiet: whether to display the output of awsebcli installation to
477496
the terminal or not
478497
:param version: the specific version of awsebcli to install
479498
:return None
480499
"""
481-
if version:
500+
if ebcli_source:
501+
install_args = ['pip', 'install', '{}'.format(ebcli_source.strip())]
502+
elif version:
482503
install_args = ['pip', 'install', 'awsebcli=={}'.format(version.strip())]
483504
else:
484505
install_args = [
@@ -665,6 +686,11 @@ def _parse_arguments():
665686
'--version',
666687
help='version of EBCLI to install'
667688
)
689+
parser.add_argument(
690+
'-s', '--ebcli-source',
691+
help='filesystem path to a Git repository of the EBCLI, or a .zip or .tar file of '
692+
'the EBCLI source code; useful when testing a development version of the EBCLI.'
693+
)
668694
return parser.parse_args()
669695

670696

@@ -735,6 +761,10 @@ def _python_script_body(virtualenv_location):
735761
arguments_context.quiet
736762
)
737763
_activate_virtualenv(virtualenv_location)
738-
_install_ebcli(arguments_context.quiet, arguments_context.version)
764+
_install_ebcli(
765+
arguments_context.quiet,
766+
arguments_context.version,
767+
arguments_context.ebcli_source
768+
)
739769
_generate_ebcli_wrappers(virtualenv_location)
740770
_announce_success(virtualenv_location)

0 commit comments

Comments
 (0)