|
@@ -1,18 +1,14 @@
|
|
|
import subprocess
|
|
|
import json
|
|
|
import sys
|
|
|
+import io
|
|
|
cmd='aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=RunInstances --max-results 20 --region us-east-1'
|
|
|
cmds=cmd.split(' ')
|
|
|
#cl=subprocess.run(cmds,text=True, capture_output=True)
|
|
|
cl=subprocess.Popen(cmds, stdout=subprocess.PIPE)
|
|
|
lst=[]
|
|
|
|
|
|
-while True:
|
|
|
- l = cl.stdout.readline()
|
|
|
- if not l:
|
|
|
- break
|
|
|
- l=str(l)
|
|
|
-
|
|
|
+for l in io.TextIOWrapper(cl.stdout, encoding="utf-8"):
|
|
|
if '"AccessKeyId":' in l:
|
|
|
lst.append(l)
|
|
|
|