Skip to content

Commit

Permalink
Merge pull request #268 from akrherz/lint
Browse files Browse the repository at this point in the history
📝 Address lint
  • Loading branch information
akrherz authored Jan 6, 2025
2 parents 70351ba + 34af501 commit e84d697
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 27 deletions.
2 changes: 0 additions & 2 deletions goes/ir_cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 0 additions & 2 deletions goes/netcdf2png.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions goes/wv_cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
18 changes: 13 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions src/pywwa/ldmbridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion src/pywwa/workflows/shef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion util/awx_metar_supplement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
31 changes: 19 additions & 12 deletions util/rotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,27 @@
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}"
newfp = f"{BASE}/{fnbase}{i + 1}.{fmt}"
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"

Expand All @@ -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)

0 comments on commit e84d697

Please sign in to comment.