mirror of
https://github.com/mbirth/tcl_ota_check.git
synced 2024-11-10 06:16:46 +00:00
Added correct URL to uploader tool. Added notice if logs collected.
This commit is contained in:
parent
3b89f3a066
commit
0da722a048
@ -55,3 +55,5 @@ if fc.mode == fc.MODE.FULL:
|
|||||||
f.write(header)
|
f.write(header)
|
||||||
else:
|
else:
|
||||||
print("Header length invalid ({}).".format(len(header)))
|
print("Header length invalid ({}).".format(len(header)))
|
||||||
|
|
||||||
|
tcllib.FotaCheck.write_info_if_dumps_found()
|
||||||
|
@ -43,3 +43,5 @@ with open("prds.txt", "rt") as f:
|
|||||||
except RequestException as e:
|
except RequestException as e:
|
||||||
print("{}: {}".format(prd, str(e)))
|
print("{}: {}".format(prd, str(e)))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
tcllib.FotaCheck.write_info_if_dumps_found()
|
||||||
|
@ -47,3 +47,5 @@ with open("prds.txt", "r") as f:
|
|||||||
except RequestException as e:
|
except RequestException as e:
|
||||||
print("{} ({}): {}".format(prd, lastver, str(e)))
|
print("{} ({}): {}".format(prd, lastver, str(e)))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
tcllib.FotaCheck.write_info_if_dumps_found()
|
||||||
|
@ -73,3 +73,4 @@ for center in sorted(prddict.keys()):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
print("Scan complete.")
|
print("Scan complete.")
|
||||||
|
tcllib.FotaCheck.write_info_if_dumps_found()
|
||||||
|
@ -61,3 +61,4 @@ for fv in allvers:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
print("Scan complete.")
|
print("Scan complete.")
|
||||||
|
tcllib.FotaCheck.write_info_if_dumps_found()
|
||||||
|
11
tcllib.py
11
tcllib.py
@ -7,6 +7,7 @@ import base64
|
|||||||
import binascii
|
import binascii
|
||||||
import enum
|
import enum
|
||||||
import errno
|
import errno
|
||||||
|
import glob
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
@ -148,6 +149,16 @@ class FotaCheck:
|
|||||||
with open(outfile, "w", encoding="utf-8") as f:
|
with open(outfile, "w", encoding="utf-8") as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def write_info_if_dumps_found():
|
||||||
|
# To disable this info, uncomment the following line.
|
||||||
|
#return
|
||||||
|
files = glob.glob(os.path.normpath("logs/*.xml"))
|
||||||
|
if len(files) > 0:
|
||||||
|
print()
|
||||||
|
print("{}There are {} logs collected in the logs/ directory.{} Please consider uploading".format(ANSI_YELLOW, len(files), ANSI_RESET))
|
||||||
|
print("them to https://tclota.birth-online.de/ by running {}./upload_logs.py{}.".format(ANSI_CYAN, ANSI_RESET))
|
||||||
|
|
||||||
def do_check(self, https=True, timeout=10, max_tries=5):
|
def do_check(self, https=True, timeout=10, max_tries=5):
|
||||||
protocol = "https://" if https else "http://"
|
protocol = "https://" if https else "http://"
|
||||||
url = protocol + self.g2master + "/check.php"
|
url = protocol + self.g2master + "/check.php"
|
||||||
|
@ -10,7 +10,7 @@ import os
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
# This is the URL to an installation of https://github.com/mbirth/tcl_update_db
|
# 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")
|
LOGS_GLOB = os.path.normpath("logs/*.xml")
|
||||||
|
|
||||||
headers = { "Content-Type": "text/xml" }
|
headers = { "Content-Type": "text/xml" }
|
||||||
@ -20,6 +20,12 @@ for fn in glob.glob(LOGS_GLOB):
|
|||||||
with open(fn, "rb") as f:
|
with open(fn, "rb") as f:
|
||||||
r = requests.post(UPLOAD_URL, data=f, headers=headers)
|
r = requests.post(UPLOAD_URL, data=f, headers=headers)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
|
os.remove(fn)
|
||||||
print(" OK")
|
print(" OK")
|
||||||
else:
|
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))
|
||||||
|
Loading…
Reference in New Issue
Block a user