mirror of
https://github.com/EeeeKa/webhook-catcher.git
synced 2025-09-24 03:42:10 +05:00
Patch for support Python 3.5
This commit is contained in:
parent
9f678a8b76
commit
6575125224
@ -67,6 +67,19 @@ DEFAULT_REMOTE = "origin"
|
|||||||
DEFAULT_BRANCH = "master"
|
DEFAULT_BRANCH = "master"
|
||||||
DEFAULT_PROTO = "http"
|
DEFAULT_PROTO = "http"
|
||||||
|
|
||||||
|
# PARAMS
|
||||||
|
# Python v3.7+
|
||||||
|
if sys.version_info.major == 3 and sys.version_info[1] > 7:
|
||||||
|
READ_SIZE = -1
|
||||||
|
# Python v3.5+
|
||||||
|
elif sys.version_info.major == 3 and sys.version_info[1] > 5:
|
||||||
|
READ_SIZE = 20480
|
||||||
|
# Fallback
|
||||||
|
else:
|
||||||
|
READ_SIZE = 20480
|
||||||
|
|
||||||
|
MAX_READ_ATTEMPTS = 10
|
||||||
|
|
||||||
class WebHookServer(_HTTPServer):
|
class WebHookServer(_HTTPServer):
|
||||||
|
|
||||||
def __init__(self, server_address, request_handler_class, repos, self_update_repo, wild_dir, wild_proto, wild_secret):
|
def __init__(self, server_address, request_handler_class, repos, self_update_repo, wild_dir, wild_proto, wild_secret):
|
||||||
@ -152,9 +165,11 @@ class WebHookHandler(BaseHTTPRequestHandler):
|
|||||||
# GET DATA
|
# GET DATA
|
||||||
data_raw = b''
|
data_raw = b''
|
||||||
data_read_complete = False
|
data_read_complete = False
|
||||||
|
read_attempt = 0
|
||||||
|
|
||||||
while not data_read_complete:
|
while not data_read_complete and read_attempt < MAX_READ_ATTEMPTS:
|
||||||
data_raw += self.rfile.read1(-1)
|
read_attempt += 1
|
||||||
|
data_raw += self.rfile.read1(READ_SIZE)
|
||||||
try:
|
try:
|
||||||
data = json.loads(data_raw.decode('UTF-8'))
|
data = json.loads(data_raw.decode('UTF-8'))
|
||||||
except:
|
except:
|
||||||
|
Loading…
Reference in New Issue
Block a user