mirror of
https://github.com/mbirth/tcl_ota_check.git
synced 2024-11-09 22:06:47 +00:00
Basic uploader.
This commit is contained in:
parent
bb1c4a6d6f
commit
2ce9a2a842
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user