diff --git a/upload_logs.py b/upload_logs.py index 110d44b..5618738 100644 --- a/upload_logs.py +++ b/upload_logs.py @@ -3,6 +3,23 @@ # pylint: disable=C0111,C0326,C0103 -import os +# curl -v -H "Content-Type: text/plain" --data @test.xml http://example.org/tcl_update_db/ +import glob +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/" LOGS_GLOB = os.path.normpath("logs/*.xml") + +headers = { "Content-Type": "text/xml" } + +for fn in glob.glob(LOGS_GLOB): + print("Uploading {}…".format(fn), end="") + with open(fn, "rb") as f: + r = requests.post(UPLOAD_URL, data=f, headers=headers) + if r.status_code == 200: + print(" OK") + else: + print(" ERROR: HTTP {}".format(r.status_code))