1
0
mirror of https://github.com/mbirth/tcl_ota_check.git synced 2024-09-19 22:33:25 +01:00
tcl_ota_check/upload_logs.py

26 lines
719 B
Python
Raw Normal View History

2017-11-02 01:05:26 +00:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# pylint: disable=C0111,C0326,C0103
2017-11-03 22:26:51 +00:00
# curl -v -H "Content-Type: text/plain" --data @test.xml http://example.org/tcl_update_db/
import glob
2017-11-02 01:34:31 +00:00
import os
2017-11-03 22:26:51 +00:00
import requests
2017-11-02 01:34:31 +00:00
2017-11-03 22:26:51 +00:00
# This is the URL to an installation of https://github.com/mbirth/tcl_update_db
UPLOAD_URL = "http://example.org/tcl_update_db/"
2017-11-02 01:44:46 +00:00
LOGS_GLOB = os.path.normpath("logs/*.xml")
2017-11-03 22:26:51 +00:00
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))