@@ -210,6 +210,10 @@ def _exec_cmd(args):
210
210
RED_COLOR_CODE = 9
211
211
212
212
213
+ class ArgumentError (Exception ):
214
+ pass
215
+
216
+
213
217
class Step (object ):
214
218
"""
215
219
Class labels an installation Step and is expected to be invoked as
@@ -330,9 +334,24 @@ def _announce_success(virtualenv_location):
330
334
331
335
332
336
def _print_in_foreground (message , color_number ):
337
+ """
338
+ Function prints a given `message` on the terminal in the foreground. `color_number`
339
+ is a number between and including 0 and 255. FOr a list of color codes see:
340
+
341
+ https://misc.flogisoft.com/bash/tip_colors_and_formatting#background1
342
+
343
+ On Windows, `color_number` is rejected, and hence not used. At present, PowerShell
344
+ is able to recognize ANSI/VT100 escape sequences, however, CMD prompt is not.
345
+
346
+ :param message: a string to print in the foreground on the terminal
347
+ :param color_number: an integer between and including 0 and 255 representing
348
+ a color
349
+ :return: None
350
+ """
333
351
if sys .platform .startswith ('win32' ):
334
352
print (message )
335
353
else :
354
+ # Courtesy https://misc.flogisoft.com/bash/tip_colors_and_formatting
336
355
print (
337
356
"\033 [38;5;{color_number}m{message}\033 [0m" .format (
338
357
color_number = color_number ,
@@ -468,17 +487,23 @@ def _generate_ebcli_wrappers(virtualenv_location):
468
487
469
488
470
489
@Step ('Installing EBCLI' )
471
- def _install_ebcli (quiet , version ):
490
+ def _install_ebcli (quiet , version , ebcli_source ):
472
491
"""
473
492
Function installs the awsebcli presumably within the virtualenv,
474
493
".ebcli-virtual-env", created and activated by this script apriori.
475
494
If `version` is passed, the specific version of the EBCLI is installed.
495
+
496
+ The presence of `version` and `ebcli_source` will lead to an exception
497
+ as they represent two different ways of installing the EBCLI.
498
+
476
499
:param quiet: whether to display the output of awsebcli installation to
477
500
the terminal or not
478
501
:param version: the specific version of awsebcli to install
479
502
:return None
480
503
"""
481
- if version :
504
+ if ebcli_source :
505
+ install_args = ['pip' , 'install' , '{}' .format (ebcli_source .strip ())]
506
+ elif version :
482
507
install_args = ['pip' , 'install' , 'awsebcli=={}' .format (version .strip ())]
483
508
else :
484
509
install_args = [
@@ -661,11 +686,24 @@ def _parse_arguments():
661
686
action = 'store_true' ,
662
687
help = 'enable quiet mode to display only minimal, necessary output'
663
688
)
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
+ )
664
694
parser .add_argument (
665
695
'-v' , '--version' ,
666
696
help = 'version of EBCLI to install'
667
697
)
668
- return parser .parse_args ()
698
+
699
+ arguments = parser .parse_args ()
700
+
701
+ if arguments .version and arguments .ebcli_source :
702
+ raise ArgumentError (
703
+ '"--version" and "--ebcli-source" cannot be used together '
704
+ 'because they represent two distinct sources of the EBCLI.'
705
+ )
706
+ return arguments
669
707
670
708
671
709
def _pip_executable_found (quiet ):
@@ -735,6 +773,10 @@ def _python_script_body(virtualenv_location):
735
773
arguments_context .quiet
736
774
)
737
775
_activate_virtualenv (virtualenv_location )
738
- _install_ebcli (arguments_context .quiet , arguments_context .version )
776
+ _install_ebcli (
777
+ arguments_context .quiet ,
778
+ arguments_context .version ,
779
+ arguments_context .ebcli_source
780
+ )
739
781
_generate_ebcli_wrappers (virtualenv_location )
740
782
_announce_success (virtualenv_location )
0 commit comments