Your Name 3 년 전
부모
커밋
3636c76e06
1개의 변경된 파일2개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 6
      hhh/aws-monitor/cl-test.py

+ 2 - 6
hhh/aws-monitor/cl-test.py

@@ -1,18 +1,14 @@
 import subprocess
 import subprocess
 import json
 import json
 import sys
 import sys
+import io
 cmd='aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=RunInstances --max-results 20 --region us-east-1'
 cmd='aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=RunInstances --max-results 20 --region us-east-1'
 cmds=cmd.split(' ')
 cmds=cmd.split(' ')
 #cl=subprocess.run(cmds,text=True, capture_output=True)
 #cl=subprocess.run(cmds,text=True, capture_output=True)
 cl=subprocess.Popen(cmds, stdout=subprocess.PIPE)
 cl=subprocess.Popen(cmds, stdout=subprocess.PIPE)
 lst=[]
 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:
     if '"AccessKeyId":' in l:
         lst.append(l)
         lst.append(l)