Permalink
Browse files

bf exec tool

	new file:   botoform/plugins/exec.py
	modified:   docs/source/tools/bf.rst
	modified:   setup.py
  • Loading branch information...
russellballestrini committed Aug 10, 2017
1 parent 176a2bd commit 7bd3f11b97113f502b7c68a15777d4d9dc89c400
Showing with 54 additions and 0 deletions.
  1. +32 −0 botoform/plugins/exec.py
  2. +21 −0 docs/source/tools/bf.rst
  3. +1 −0 setup.py
View
@@ -0,0 +1,32 @@
import sys
def Exec(args, evpc):
"""
Accept a Python program on STDIN and execute it.
The following examples query all active AMI ids from a VPC
named `dogtest01` in the `development` AWS account profile.
The first example is best for short one liners, the second is prefered for bigger scripts.
Usage 1 (echo and pipe)::
echo "print(set([i.image_id for i in evpc.instances]))" | bf --profile development exec dogtest01
Usage 2 (redirection)::
bf --profile development exec dogtest01 < unique_running_amis.py
Where `unique_running_amis.py` has the following content::
print(set([i.image_id for i in evpc.instances]))
In this example, for following would look something like this::
set(['ami-33333333', 'ami-55555555', 'ami-99999999', 'ami-77777777'])
:param args: The parsed arguments and flags from the CLI.
:param evpc: An instance of :meth:`botoform.enriched.vpc.EnrichedVPC`.
"""
script = sys.stdin.read()
exec(script)
View
@@ -145,6 +145,27 @@ shell
An alias to repl_ so it works the same.
exec
----
Accept a Python program on STDIN and execute it.
Usage 1 (echo and pipe)::
echo "print(set([i.image_id for i in evpc.instances]))" | bf --profile development exec dogtest01
Usage 2 (redirection)::
bf --profile development exec dogtest01 < unique_running_amis.py
Where `unique_running_amis.py` has the following content::
print(set([i.image_id for i in evpc.instances]))
In this example, for following would look something like this::
set(['ami-33333333', 'ami-55555555', 'ami-99999999', 'ami-77777777'])
dump
----
View
@@ -38,6 +38,7 @@
'repl = botoform.plugins.repl:REPL',
'cli = botoform.plugins.repl:REPL',
'shell = botoform.plugins.repl:REPL',
'exec = botoform.plugins.exec:Exec',
'refresh = botoform.plugins.refresh:Refresh',
'atmosphere = botoform.plugins.atmosphere:Atmosphere',
],

0 comments on commit 7bd3f11

Please sign in to comment.