From cf06d6fb56aab20ad327e13103936161f382b111 Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Tue, 22 Jul 2014 00:22:58 -0400 Subject: [PATCH] Added awslib, for interacting with Amazon AWS. --- planetstack/ec2_observer/awslib.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 planetstack/ec2_observer/awslib.py diff --git a/planetstack/ec2_observer/awslib.py b/planetstack/ec2_observer/awslib.py new file mode 100644 index 0000000..5df0768 --- /dev/null +++ b/planetstack/ec2_observer/awslib.py @@ -0,0 +1,18 @@ +import os +import json + +class AwsException(Exception): + pass + +def aws_run(cmd): + cmd = 'aws %s'%cmd + pipe = os.popen(cmd) + output_str = pipe.read() + + if (not pipe.close()): + output = json.loads(output_str) + return output + else: + raise AwsException("Error: %s"%output_str) + + -- 2.47.0