소스 검색

Make S3 response pattern matching more flexible (so it also works on Scaleway)

master
JustAnotherArchivist 2 년 전
부모
커밋
95988466ec
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. +5
    -1
      s3-bucket-list

+ 5
- 1
s3-bucket-list 파일 보기

@@ -3,12 +3,16 @@ import html
import http.client
import json
import os
import re
import shlex
import ssl
import sys
import urllib.parse


RESPONSE_PATTERN = re.compile(r'''^<\?xml version=(["'])1\.0\1 encoding=(["'])UTF-8\2\?>''' '\n?' r'''<ListBucketResult xmlns=(["'])http://(?:s3\.amazonaws\.com/doc/2006-03-01/|doc\.s3\.amazonaws\.com/2006-03-01)\3>'''.encode('ascii'))


# Arguments
i = 1
withListUrls = False
@@ -79,7 +83,7 @@ while True:
break
attempt += 1
continue
if not body.startswith(b'<?xml version="1.0" encoding="UTF-8"?>\n<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">') and not body.startswith(b"<?xml version='1.0' encoding='UTF-8'?><ListBucketResult xmlns='http://doc.s3.amazonaws.com/2006-03-01'>"):
if not RESPONSE_PATTERN.match(body):
raise RuntimeError(f'Invalid body: {body[:200]}...')

if b'<Marker></Marker>' in body[:200] and 'marker' in params:


불러오는 중...
취소
저장