1
0

Added correct URL to uploader tool. Added notice if logs collected.

This commit is contained in:
2017-11-12 22:19:04 +01:00
parent 3b89f3a066
commit 0da722a048
7 changed files with 27 additions and 2 deletions
+8 -2
View File
@@ -10,7 +10,7 @@ import os
import requests
# This is the URL to an installation of https://github.com/mbirth/tcl_update_db
UPLOAD_URL = "http://example.org/tcl_update_db/"
UPLOAD_URL = "https://tclota.birth-online.de/"
LOGS_GLOB = os.path.normpath("logs/*.xml")
headers = { "Content-Type": "text/xml" }
@@ -20,6 +20,12 @@ for fn in glob.glob(LOGS_GLOB):
with open(fn, "rb") as f:
r = requests.post(UPLOAD_URL, data=f, headers=headers)
if r.status_code == 200:
os.remove(fn)
print(" OK")
else:
print(" ERROR: HTTP {}".format(r.status_code))
add_text = ""
if r.status_code in [413, 406, 412]:
# File has been rejected by server, another try won't help
os.remove(fn)
add_text = " - Please try again later."
print(" ERROR: HTTP {}{}".format(r.status_code, add_text))