From 2ce9a2a842d451b287fa8911ea4832df96c2ae22 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Fri, 3 Nov 2017 23:26:51 +0100 Subject: [PATCH] Basic uploader. --- upload_logs.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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))