Sapan Bhatia | cf06d6f | 2014-07-22 00:22:58 -0400 | [diff] [blame] | 1 | import os |
2 | import json | ||||
3 | |||||
4 | class AwsException(Exception): | ||||
5 | pass | ||||
6 | |||||
Sapan Bhatia | d14dec2 | 2014-09-08 03:26:35 -0400 | [diff] [blame] | 7 | def aws_run(cmd,env=''): |
8 | cmd = '%s aws %s'%(env,cmd) | ||||
Sapan Bhatia | cf06d6f | 2014-07-22 00:22:58 -0400 | [diff] [blame] | 9 | pipe = os.popen(cmd) |
10 | output_str = pipe.read() | ||||
11 | |||||
12 | if (not pipe.close()): | ||||
13 | output = json.loads(output_str) | ||||
14 | return output | ||||
15 | else: | ||||
16 | raise AwsException("Error: %s"%output_str) | ||||
17 | |||||
18 |