diff --git a/goes/ir_cmap.py b/goes/ir_cmap.py index bf689ae6..f79d737e 100644 --- a/goes/ir_cmap.py +++ b/goes/ir_cmap.py @@ -64,5 +64,3 @@ for i in range(256): c = cmap(i / 255.0) print("%.2f %.0f %.0f %.0f" % (i, c[0] * 255, c[1] * 255, c[2] * 255)) -# vmax = 54.4 -# vmin = -109. diff --git a/goes/netcdf2png.py b/goes/netcdf2png.py index 5bb1fe27..df3e12a5 100644 --- a/goes/netcdf2png.py +++ b/goes/netcdf2png.py @@ -185,12 +185,10 @@ def main(argv): # we double back with the netcdf read statement above closing. if "IN_CLOSE_WRITE" not in type_names: continue - # LOG.debug("fn: %s type_names: %s", fn, type_names) if not fn.endswith(".nc") or fn.find(bird) == -1: continue ncfn = f"{watch_path}/{fn}" try: - # LOG.debug("Processing %s", ncfn) process(ncfn) except Exception as exp: # Full disk will cause grief diff --git a/goes/wv_cmap.py b/goes/wv_cmap.py index 2595ca01..006846ab 100644 --- a/goes/wv_cmap.py +++ b/goes/wv_cmap.py @@ -25,5 +25,3 @@ val = -109.5 + (i / 255) * (54.5 + 109.5) c = cmap(i / 255.0) print("%.2f %.0f %.0f %.0f" % (val, c[0] * 255, c[1] * 255, c[2] * 255)) -# vmax = 54.4 -# vmin = -109. diff --git a/pyproject.toml b/pyproject.toml index 662077c0..b237cb9a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,11 +98,19 @@ target-version = "py39" line-length = 79 lint.select = [ - "B", # bugbear - "E", - "F", - "I", - "T", + "A", # builtins + "B", # bugbear + "E", # pycodestyle + "ERA", # commented out code + "F", # pyflakes + # "FIX", # FIXME + "G", # logging-format + "I", # isort + "NPY", # numpy + "PLW", # pylint-warning + "S324", # security + "T", # print + "W", # pycodestyle ] lint.per-file-ignores."goes/*.py" = [ "T201", diff --git a/src/pywwa/ldmbridge.py b/src/pywwa/ldmbridge.py index f8777316..e219095b 100644 --- a/src/pywwa/ldmbridge.py +++ b/src/pywwa/ldmbridge.py @@ -82,8 +82,9 @@ def filter_product(self, original): clean = "\015\015\012".join(lines) # first 11 characters should not be included in hex, like LDM does # hashlib works on bytes - # skipcq: PTC-W1003 - digest = hashlib.md5(clean[11:].encode("utf-8")).hexdigest() + digest = hashlib.md5( + clean[11:].encode("utf-8"), usedforsecurity=False + ).hexdigest() if digest in self.cache: log.msg(f"DUP! {','.join(lines[1:5])}") else: diff --git a/src/pywwa/workflows/shef.py b/src/pywwa/workflows/shef.py index 90b7a52a..bd053ce9 100644 --- a/src/pywwa/workflows/shef.py +++ b/src/pywwa/workflows/shef.py @@ -200,7 +200,6 @@ def restructure_data(prod): """Create a nicer data structure for future processing.""" mydata = {} # Step 1: Restructure and do some cleaning - # se == SHEFElement old = [] utcnow = common.utcnow() for se in prod.data: diff --git a/util/awx_metar_supplement.py b/util/awx_metar_supplement.py index 6ef653cb..2f1bbf64 100644 --- a/util/awx_metar_supplement.py +++ b/util/awx_metar_supplement.py @@ -61,7 +61,7 @@ def main(network): time.sleep(5) continue if req.status_code != 200: - LOG.warning(f"Failed to fetch {st4} {req.status_code}") + LOG.warning("Failure %s %s", st4, req.status_code) continue break except Exception as exp: diff --git a/util/rotate.py b/util/rotate.py index 1ca4e5cb..34a8d324 100644 --- a/util/rotate.py +++ b/util/rotate.py @@ -3,20 +3,13 @@ import gzip import os import sys +from io import BytesIO BASE = "/mesonet/ldmdata/" -def main(argv): - """Do SOmething""" - data = sys.stdin.buffer.read() - fnbase = argv[1] - fmt = argv[2] - - dirname = f"{BASE}/{os.path.dirname(fnbase)}" - if not os.path.isdir(dirname): - os.makedirs(dirname) - +def handler(fnbase: str, fmt: str, bio: BytesIO): + """Do things.""" if fmt == "tif.Z": for i in range(10, -1, -1): oldfp = f"{BASE}/{fnbase}{i}.{fmt}" @@ -24,10 +17,13 @@ def main(argv): if os.path.isfile(oldfp): os.rename(oldfp, newfp) + # Write out the compressed version verbatim with open(f"{BASE}/{fnbase}0.{fmt}", "wb") as fh: - fh.write(data) + fh.write(bio.getvalue()) - with gzip.open(f"{BASE}/{fnbase}0.{fmt}", "rb") as fh: + # Create the uncompressed version + bio.seek(0) + with gzip.open(bio, "rb") as fh: data = fh.read() fmt = "tif" @@ -41,5 +37,16 @@ def main(argv): fh.write(data) +def main(argv): + """Do SOmething""" + fnbase = argv[1] + fmt = argv[2] + dirname = f"{BASE}/{os.path.dirname(fnbase)}" + if not os.path.isdir(dirname): + os.makedirs(dirname) + with BytesIO(sys.stdin.buffer.read()) as bio: + handler(fnbase, fmt, bio) + + if __name__ == "__main__": main(sys.argv)